add generator to create a list of all the deprecated options that the fixers fix
fix location of deprecated_options code
This commit is contained in:
parent
15b14d4879
commit
b28059c0a5
1
Makefile
1
Makefile
|
@ -125,6 +125,7 @@ generate: install-gen-deps ## Generate dynamically generated code
|
||||||
@find post-processor common helper template builder provisioner -type f | xargs grep -l '^// Code generated' | xargs rm
|
@find post-processor common helper template builder provisioner -type f | xargs grep -l '^// Code generated' | xargs rm
|
||||||
go generate ./...
|
go generate ./...
|
||||||
go fmt common/bootcommand/boot_command.go
|
go fmt common/bootcommand/boot_command.go
|
||||||
|
go run ./cmd/generate-fixer-deprecations
|
||||||
|
|
||||||
generate-check: generate ## Check go code generation is on par
|
generate-check: generate ## Check go code generation is on par
|
||||||
@echo "==> Checking that auto-generated code is not changed..."
|
@echo "==> Checking that auto-generated code is not changed..."
|
||||||
|
|
|
@ -0,0 +1,74 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"text/template"
|
||||||
|
|
||||||
|
"github.com/hashicorp/packer/fix"
|
||||||
|
)
|
||||||
|
|
||||||
|
var deprecatedOptsTemplate = template.Must(template.New("deprecatedOptsTemplate").
|
||||||
|
Parse(`//<!-- Code generated by generate-fixer-deprecations; DO NOT EDIT MANUALLY -->
|
||||||
|
|
||||||
|
package config
|
||||||
|
|
||||||
|
var DeprecatedOptions = []string{
|
||||||
|
{{- range .DeprecatedOpts}}
|
||||||
|
"{{.}}",
|
||||||
|
{{- end}}
|
||||||
|
}`))
|
||||||
|
|
||||||
|
type executeOpts struct {
|
||||||
|
DeprecatedOpts []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Figure out location in directory structure
|
||||||
|
args := flag.Args()
|
||||||
|
if len(args) == 0 {
|
||||||
|
// Default: process the file
|
||||||
|
args = []string{os.Getenv("GOFILE")}
|
||||||
|
}
|
||||||
|
fname := args[0]
|
||||||
|
|
||||||
|
absFilePath, err := filepath.Abs(fname)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
paths := strings.SplitAfter(absFilePath, "packer"+string(os.PathSeparator))
|
||||||
|
packerDir := paths[0]
|
||||||
|
|
||||||
|
// Load all deprecated options from all active fixers
|
||||||
|
allDeprecatedOpts := []string{}
|
||||||
|
for _, name := range fix.FixerOrder {
|
||||||
|
fixer, ok := fix.Fixers[name]
|
||||||
|
if !ok {
|
||||||
|
panic("fixer not found: " + name)
|
||||||
|
}
|
||||||
|
|
||||||
|
deprecated := fixer.DeprecatedOptions()
|
||||||
|
for _, dep := range deprecated {
|
||||||
|
allDeprecatedOpts = append(allDeprecatedOpts, dep)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deprecated_path := filepath.Join(packerDir, "helper", "config",
|
||||||
|
"deprecated_options.go")
|
||||||
|
|
||||||
|
outputFile, err := os.Create(deprecated_path)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer outputFile.Close()
|
||||||
|
|
||||||
|
deprecated := &executeOpts{DeprecatedOpts: allDeprecatedOpts}
|
||||||
|
err = deprecatedOptsTemplate.Execute(outputFile, deprecated)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("%v", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
//<!-- Code generated by generate-fixer-deprecations; DO NOT EDIT MANUALLY -->
|
||||||
|
|
||||||
|
package config
|
||||||
|
|
||||||
|
var DeprecatedOptions = []string{
|
||||||
|
"iso_md5",
|
||||||
|
"guest_additions_attach",
|
||||||
|
"headless",
|
||||||
|
"parallels_tools_host_path",
|
||||||
|
"guest_os_distribution",
|
||||||
|
"ssh_key_path",
|
||||||
|
"ssh_disable_agent",
|
||||||
|
"access_key",
|
||||||
|
"filename",
|
||||||
|
"shutdown_behaviour",
|
||||||
|
"enhanced_networking",
|
||||||
|
"ssh_private_ip",
|
||||||
|
"login_email",
|
||||||
|
"tag",
|
||||||
|
"vhd_temp_path",
|
||||||
|
"clone_from_vmxc_path",
|
||||||
|
"cpu",
|
||||||
|
"ram_size",
|
||||||
|
"clean_image_name",
|
||||||
|
"clean_ami_name",
|
||||||
|
"spot_price_auto_product",
|
||||||
|
"galaxycommand",
|
||||||
|
"ssh_host_port_min",
|
||||||
|
"ssh_host_port_max",
|
||||||
|
"ssh_skip_nat_mapping",
|
||||||
|
"ssh_wait_timeout",
|
||||||
|
"network_card",
|
||||||
|
"network",
|
||||||
|
"networkCard",
|
||||||
|
"iso_checksum_url",
|
||||||
|
"iso_checksum_type",
|
||||||
|
}
|
Loading…
Reference in New Issue