Skip to content

Commit

Permalink
add initial support for user provided ignition drop-ins
Browse files Browse the repository at this point in the history
Signed-off-by: António Meireles <[email protected]>
  • Loading branch information
AntonioMeireles committed Nov 16, 2016
1 parent dabe6ed commit c62ee1f
Show file tree
Hide file tree
Showing 11 changed files with 280 additions and 149 deletions.
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

0 comments on commit c62ee1f

Please sign in to comment.