Skip to content
This repository was archived by the owner on Sep 18, 2020. It is now read-only.

Commit

Permalink
Merge pull request #154 from dgonyeo/empty-fields
Browse files Browse the repository at this point in the history
config: make getCliArgs handle pointers, make etcd.EnableV2 a pointer
  • Loading branch information
Derek Gonyeo authored May 16, 2018
2 parents ac4a2c7 + eb40160 commit 5fde54b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
28 changes: 28 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1795,6 +1795,34 @@ func TestParseAndConvert(t *testing.T) {
}{
{
in: in{data: `
etcd:
enable_v2: false
version: 3.3.1
`},
out: out{
cfg: ignTypes.Config{
Ignition: ignTypes.Ignition{
Version: "2.2.0",
},
Systemd: ignTypes.Systemd{
Units: []ignTypes.Unit{
{
Name: "etcd-member.service",
Enable: true,
Dropins: []ignTypes.SystemdDropin{
{
Name: "20-clct-etcd-member.conf",
Contents: "[Service]\nEnvironment=\"ETCD_IMAGE_TAG=v3.3.1\"\nExecStart=\nExecStart=/usr/lib/coreos/etcd-wrapper $ETCD_OPTS \\\n --enable-v2=false",
},
},
},
},
},
},
},
},
{
in: in{data: `
networkd:
units:
- name: bad.blah
Expand Down
3 changes: 3 additions & 0 deletions config/types/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ func getArgs(format, tagName string, e interface{}) []string {
vars = append(vars, getCliArgs(val)...)
} else {
key := et.Field(i).Tag.Get(tagName)
if ev.Field(i).Kind() == reflect.Ptr {
val = reflect.Indirect(ev.Field(i)).Interface()
}
if _, ok := val.(string); ok {
// to handle whitespace characters
val = fmt.Sprintf("%q", val)
Expand Down
4 changes: 2 additions & 2 deletions config/types/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ type Etcd3_2 struct {
HeartbeatInterval int `yaml:"heartbeat_interval" cli:"heartbeat-interval"`
ElectionTimeout int `yaml:"election_timeout" cli:"election-timeout"`
EnablePprof bool `yaml:"enable_pprof" cli:"enable-pprof"`
EnableV2 bool `yaml:"enable_v2" cli:"enable-v2"`
EnableV2 *bool `yaml:"enable_v2" cli:"enable-v2"`
ListenPeerUrls string `yaml:"listen_peer_urls" cli:"listen-peer-urls"`
ListenClientUrls string `yaml:"listen_client_urls" cli:"listen-client-urls"`
MaxSnapshots int `yaml:"max_snapshots" cli:"max-snapshots"`
Expand Down Expand Up @@ -316,7 +316,7 @@ type Etcd3_3 struct {
HeartbeatInterval int `yaml:"heartbeat_interval" cli:"heartbeat-interval"`
ElectionTimeout int `yaml:"election_timeout" cli:"election-timeout"`
EnablePprof bool `yaml:"enable_pprof" cli:"enable-pprof"`
EnableV2 bool `yaml:"enable_v2" cli:"enable-v2"`
EnableV2 *bool `yaml:"enable_v2" cli:"enable-v2"`
ListenPeerUrls string `yaml:"listen_peer_urls" cli:"listen-peer-urls"`
ListenClientUrls string `yaml:"listen_client_urls" cli:"listen-client-urls"`
MaxSnapshots int `yaml:"max_snapshots" cli:"max-snapshots"`
Expand Down

0 comments on commit 5fde54b

Please sign in to comment.