Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add initial support for user provided ignition drop-ins #101

Open
wants to merge 1 commit into
base: golang
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ func loadCommand(cmd *cobra.Command, args []string) (err error) {

for x, xx := range setup.AllSettings() {
if reflect.ValueOf(x).Kind() != reflect.Map {
x = strings.Replace(x, "_", "-", -1)
vmDefs[name].Set(x, xx)
}
}
for x, xx := range def.(map[string]interface{}) {
x = strings.Replace(x, "_", "-", -1)
vmDefs[name].Set(x, xx)
}
vmDefs[name].Set("name", name)
Expand Down
21 changes: 19 additions & 2 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,16 @@ func vmBootstrap(args *viper.Viper) (vm *server.VMInfo, err error) {
vm.Ethernet =
append(vm.Ethernet, server.NetworkInterface{Type: server.Raw})

err = vm.ValidateCloudConfig(args.GetString("cloud_config"))
fuzeCfgs := viperStringSliceBugWorkaround(
args.GetStringSlice("ignition-fuze-config"))

if args.GetString("cloud-config") != "" && len(fuzeCfgs) != 0 {
err = fmt.Errorf("you can either use cloud-config or " +
"ignition-fuze-config")
return
}
err = vm.ValidateUserProvidedConfigs(
args.GetString("cloud-config"), fuzeCfgs)
if err != nil {
return
}
Expand All @@ -209,8 +218,11 @@ func runFlagsDefaults(setFlag *pflag.FlagSet) {
setFlag.IntP("memory", "m", 1024,
"VM's RAM, in MB, per instance (1024 < memory < 8192)")
setFlag.IntP("cpus", "N", 1, "VM number of virtual CPUs")
setFlag.StringP("cloud_config", "L", "",
setFlag.StringP("cloud-config", "L", "",
"cloud-config file location (either an URL or a local path)")
setFlag.StringSliceP("ignition-fuze-config", "I", nil,
"ignition fuze drop-ins file(s) location "+
"(either an URL or a local path)")
setFlag.StringP("sshkey", "k", "", "VM's default ssh key")
setFlag.StringP("root", "r", "", "append a (persistent) root volume to VM")
setFlag.BoolP("format-root", "F", false,
Expand All @@ -230,6 +242,11 @@ func runFlagsDefaults(setFlag *pflag.FlagSet) {
setFlag.MarkHidden("tap")
setFlag.MarkHidden("extra")
setFlag.MarkHidden("boot")
setFlag.SetNormalizeFunc(wordSepNormalizeFunc)
}

func wordSepNormalizeFunc(f *pflag.FlagSet, name string) pflag.NormalizedName {
return pflag.NormalizedName(strings.Replace(name, "_", "-", -1))
}

func init() {
Expand Down
8 changes: 4 additions & 4 deletions components/common/assets/assets_vfsdata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,20 @@ passwd:
users:
- name: core
ssh_authorized_keys:
{{ range $element := .SSHAuthorizedKeys }}
{{ range $element := .SSHAuthorizedKeys -}}
- {{$element}}
{{end}}
{{end}}

{{- if .UserProvidedFuzeConfigs -}}
ignition:
config:
append:
{{ range $a,$b := .UserProvidedFuzeConfigs -}}
- source: {{$.CorectldEndpoint}}/ignition/append/{{$a}}
{{end}}
{{ end }}

storage:
{{ if .SetupRoot }}
disks:
Expand Down Expand Up @@ -77,7 +87,7 @@ networkd:
[Network]
DHCP=yes
DNS={{.NetworkdGateway}}
Domains={{.NetworkdDns}}
Domains={{.DomainName}}
[DHCP]
UseDomains=true
Expand Down
Loading