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 14, 2016
1 parent 2b39d3c commit df427fa
Show file tree
Hide file tree
Showing 10 changed files with 280 additions and 151 deletions.
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 @@ -228,6 +240,11 @@ func runFlagsDefaults(setFlag *pflag.FlagSet) {
// available but hidden...
setFlag.StringP("tap", "t", "", "append tap interface to VM")
setFlag.MarkHidden("tap")
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 df427fa

Please sign in to comment.