refactor(systemd): don't allow users to set DropIn=true yet

This commit is contained in:
Jonathan Boulle 2014-05-12 15:20:08 -07:00
parent 31cfad91e3
commit cdee32d245
2 changed files with 26 additions and 2 deletions

View File

@ -144,7 +144,7 @@ ssh_authorized_keys:
` `
cfg, err := NewCloudConfig(contents) cfg, err := NewCloudConfig(contents)
if err != nil { if err != nil {
t.Fatalf("Encountered unexpected error :%v", err) t.Fatalf("Encountered unexpected error: %v", err)
} }
keys := cfg.SSHAuthorizedKeys keys := cfg.SSHAuthorizedKeys
@ -162,6 +162,26 @@ func TestCloudConfigSerializationHeader(t *testing.T) {
} }
} }
// TestDropInIgnored asserts that users are unable to set DropIn=True on units
func TestDropInIgnored(t *testing.T) {
contents := `
coreos:
units:
- name: test
dropin: true
`
cfg, err := NewCloudConfig(contents)
if err != nil || len(cfg.Coreos.Units) != 1 {
t.Fatalf("Encountered unexpected error: %v", err)
}
if len(cfg.Coreos.Units) != 1 || cfg.Coreos.Units[0].Name != "test" {
t.Fatalf("Expected 1 unit, but got %d: %v", len(cfg.Coreos.Units), cfg.Coreos.Units)
}
if cfg.Coreos.Units[0].DropIn {
t.Errorf("dropin option on unit in cloud-config was not ignored!")
}
}
func TestCloudConfigUsers(t *testing.T) { func TestCloudConfigUsers(t *testing.T) {
contents := ` contents := `
users: users:

View File

@ -27,7 +27,11 @@ type Unit struct {
Runtime bool Runtime bool
Content string Content string
Command string Command string
DropIn bool // drop-in configuration? if so, a cloudinit.conf will be generated
// For drop-in units, a cloudinit.conf is generated.
// This is currently unbound in YAML (and hence unsettable in cloud-config files)
// until the correct behaviour for multiple drop-in units is determined.
DropIn bool `yaml:"-"`
} }
func (u *Unit) Type() string { func (u *Unit) Type() string {