From 9f38792d43185f6593381a80c037e32cb60d5ebc Mon Sep 17 00:00:00 2001 From: Brandon Philips Date: Tue, 6 May 2014 18:11:28 -0700 Subject: [PATCH] fix(initialize): use REBOOT_STRATEGY in update.conf Change from STRATEGY to REBOOT_STRATEGY and update the function names to reflect that this is a config now. --- initialize/config.go | 2 +- initialize/locksmith.go | 8 ++++---- initialize/locksmith_test.go | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/initialize/config.go b/initialize/config.go index 9c1f12a..4cdcc3a 100644 --- a/initialize/config.go +++ b/initialize/config.go @@ -130,7 +130,7 @@ func Apply(cfg CloudConfig, env *Environment) error { } if s, ok := cfg.Coreos.Update["reboot-strategy"]; ok { - if err := WriteLocksmithEnvironment(s, env.Root()); err != nil { + if err := WriteLocksmithConfig(s, env.Root()); err != nil { log.Fatalf("Failed to write locksmith config to filesystem: %v", err) } log.Printf("Wrote locksmith config file to filesystem") diff --git a/initialize/locksmith.go b/initialize/locksmith.go index f696beb..2d383bf 100644 --- a/initialize/locksmith.go +++ b/initialize/locksmith.go @@ -40,10 +40,10 @@ func addStrategy(strategy string, root string) error { scanner := bufio.NewScanner(conf) sawStrat := false - stratLine := "STRATEGY="+strategy + stratLine := "REBOOT_STRATEGY="+strategy for scanner.Scan() { line := scanner.Text() - if strings.HasPrefix(line, "STRATEGY=") { + if strings.HasPrefix(line, "REBOOT_STRATEGY=") { line = stratLine sawStrat = true } @@ -60,8 +60,8 @@ func addStrategy(strategy string, root string) error { return os.Rename(tmp.Name(), etcUpdate) } -// WriteLocksmithEnvironment writes a drop-in unit for locksmith -func WriteLocksmithEnvironment(strategy string, root string) error { +// WriteLocksmithConfig updates the `update.conf` file with a REBOOT_STRATEGY for locksmith. +func WriteLocksmithConfig(strategy string, root string) error { cmd := "restart" if strategy == "off" { err := system.MaskUnit(locksmithUnit, root) diff --git a/initialize/locksmith_test.go b/initialize/locksmith_test.go index 7be9ed5..c6bceae 100644 --- a/initialize/locksmith_test.go +++ b/initialize/locksmith_test.go @@ -12,11 +12,11 @@ const ( GROUP=thegroupc` configured = base + ` -STRATEGY=awesome +REBOOT_STRATEGY=awesome ` expected = base + ` -STRATEGY=etcd-lock +REBOOT_STRATEGY=etcd-lock ` ) @@ -44,7 +44,7 @@ func TestLocksmithEnvironmentWrittenToDisk(t *testing.T) { } } - if err := WriteLocksmithEnvironment("etcd-lock", dir); err != nil { + if err := WriteLocksmithConfig("etcd-lock", dir); err != nil { t.Fatalf("Processing of LocksmithEnvironment failed: %v", err) } @@ -77,7 +77,7 @@ func TestLocksmithEnvironmentMasked(t *testing.T) { defer os.RemoveAll(dir) setupFixtures(dir) - if err := WriteLocksmithEnvironment("off", dir); err != nil { + if err := WriteLocksmithConfig("off", dir); err != nil { t.Fatalf("Processing of LocksmithEnvironment failed: %v", err) }