veyron/services/mgmt: using camel case for constant names
Change-Id: Ic6315a18d2fbee39bfff97faceca15f7146c8f36
diff --git a/services/mgmt/node/impl/const.go b/services/mgmt/node/impl/const.go
index 081a7ed..5fa0c16 100644
--- a/services/mgmt/node/impl/const.go
+++ b/services/mgmt/node/impl/const.go
@@ -1,8 +1,16 @@
package impl
-// Node manager environment variables.
const (
- PREVIOUS_ENV = "VEYRON_NM_PREVIOUS"
- ORIGIN_ENV = "VEYRON_NM_ORIGIN"
- ROOT_ENV = "VEYRON_NM_ROOT"
+ // PreviousEnv is the name of the environment variable that holds
+ // the path to the workspace that contains the previous version of
+ // the node manager.
+ PreviousEnv = "VEYRON_NM_PREVIOUS"
+ // OriginEnv is the name of the environment variable that holds the
+ // veyron name of the application repository that can be used to
+ // retrieve the node manager application envelope.
+ OriginEnv = "VEYRON_NM_ORIGIN"
+ // RootEnv is the name of the environment variable that holds the
+ // path to the directory in which node manager workspaces are
+ // created.
+ RootEnv = "VEYRON_NM_ROOT"
)
diff --git a/services/mgmt/node/impl/impl_test.go b/services/mgmt/node/impl/impl_test.go
index 6044630..9876192 100644
--- a/services/mgmt/node/impl/impl_test.go
+++ b/services/mgmt/node/impl/impl_test.go
@@ -31,7 +31,7 @@
)
const (
- TEST_ENV = "VEYRON_NM_TEST"
+ testEnv = "VEYRON_NM_TEST"
)
var (
@@ -51,7 +51,7 @@
func (i *arInvoker) Match(ipc.ServerContext, []string) (application.Envelope, error) {
vlog.VI(0).Infof("Match()")
envelope := generateEnvelope()
- envelope.Env = exec.Setenv(envelope.Env, TEST_ENV, "child")
+ envelope.Env = exec.Setenv(envelope.Env, testEnv, "child")
envelope.Binary = "cr"
return *envelope, nil
}
@@ -117,7 +117,7 @@
}
func generateLink(root, workspace string) {
- link := filepath.Join(root, impl.CURRENT)
+ link := filepath.Join(root, impl.CurrentWorkspace)
newLink := link + ".new"
fi, err := os.Lstat(newLink)
if err == nil {
@@ -135,7 +135,7 @@
func generateScript(workspace, binary string) string {
envelope := generateEnvelope()
- envelope.Env = exec.Setenv(envelope.Env, TEST_ENV, "parent")
+ envelope.Env = exec.Setenv(envelope.Env, testEnv, "parent")
output := "#!/bin/bash\n"
output += strings.Join(envelope.Env, " ") + " "
output += binary + " " + strings.Join(envelope.Args, " ")
@@ -184,8 +184,8 @@
// nodeManager is an enclosure for setting up and starting the parent
// and child node manager used by the TestUpdate() method.
func nodeManager(argv []string) {
- root := os.Getenv(impl.ROOT_ENV)
- switch os.Getenv(TEST_ENV) {
+ root := os.Getenv(impl.RootEnv)
+ switch os.Getenv(testEnv) {
case "setup":
workspace := filepath.Join(root, fmt.Sprintf("%v", time.Now().Format(time.RFC3339Nano)))
perm := os.FileMode(0755)
@@ -230,9 +230,9 @@
child := blackbox.HelperCommand(t, "nodeManager")
child.Cmd.Env = exec.Setenv(child.Cmd.Env, "NAMESPACE_ROOT", mtName)
child.Cmd.Env = exec.Setenv(child.Cmd.Env, "VEYRON_IDENTITY", idFile)
- child.Cmd.Env = exec.Setenv(child.Cmd.Env, impl.ORIGIN_ENV, "ar")
- child.Cmd.Env = exec.Setenv(child.Cmd.Env, impl.ROOT_ENV, root)
- child.Cmd.Env = exec.Setenv(child.Cmd.Env, TEST_ENV, "setup")
+ child.Cmd.Env = exec.Setenv(child.Cmd.Env, impl.OriginEnv, "ar")
+ child.Cmd.Env = exec.Setenv(child.Cmd.Env, impl.RootEnv, root)
+ child.Cmd.Env = exec.Setenv(child.Cmd.Env, testEnv, "setup")
if err := child.Cmd.Start(); err != nil {
t.Fatalf("Start() failed: %v", err)
}
@@ -331,9 +331,9 @@
suffix, envelope := "", &application.Envelope{}
name := naming.MakeTerminal(naming.JoinAddressName(endpoint.String(), suffix))
vlog.VI(0).Infof("Node manager name: %v", name)
- // TODO(jsimsa): Replace PREVIOUS_ENV with a command-line flag when
+ // TODO(jsimsa): Replace <PreviousEnv> with a command-line flag when
// command-line flags in tests are supported.
- dispatcher := impl.NewDispatcher(nil, envelope, name, os.Getenv(impl.PREVIOUS_ENV))
+ dispatcher := impl.NewDispatcher(nil, envelope, name, os.Getenv(impl.PreviousEnv))
if err := server.Register(suffix, dispatcher); err != nil {
vlog.Fatalf("Register(%v, %v) failed: %v", suffix, dispatcher, err)
}
diff --git a/services/mgmt/node/impl/invoker.go b/services/mgmt/node/impl/invoker.go
index 46fd993..d230ed7 100644
--- a/services/mgmt/node/impl/invoker.go
+++ b/services/mgmt/node/impl/invoker.go
@@ -55,7 +55,7 @@
"veyron2/vlog"
)
-const CURRENT = "current"
+const CurrentWorkspace = "current"
var appsSuffix = regexp.MustCompile(`^apps\/.*$`)
@@ -401,7 +401,7 @@
return nil
}
-// TODO(jsimsa): Replace PREVIOUS_ENV with a command-line flag when
+// TODO(jsimsa): Replace <PreviousEnv> with a command-line flag when
// command-line flags in tests are supported.
func generateScript(workspace string, envelope *application.Envelope) error {
path, err := filepath.EvalSymlinks(os.Args[0])
@@ -410,7 +410,7 @@
return errOperationFailed
}
output := "#!/bin/bash\n"
- output += PREVIOUS_ENV + "=" + filepath.Dir(path) + " "
+ output += PreviousEnv + "=" + filepath.Dir(path) + " "
output += strings.Join(envelope.Env, " ") + " "
output += os.Args[0] + " " + strings.Join(envelope.Args, " ")
path = filepath.Join(workspace, "noded.sh")
@@ -424,7 +424,7 @@
// getCurrentFileInfo returns the os.FileInfo for both the symbolic
// link $VEYRON_NM_ROOT/current and the workspace this link points to.
func getCurrentFileInfo() (os.FileInfo, os.FileInfo, error) {
- path := filepath.Join(os.Getenv(ROOT_ENV), CURRENT)
+ path := filepath.Join(os.Getenv(RootEnv), CurrentWorkspace)
link, err := os.Lstat(path)
if err != nil {
vlog.Errorf("Lstat(%v) failed: %v", path, err)
@@ -439,7 +439,7 @@
}
func updateLink(workspace string) error {
- link := filepath.Join(os.Getenv(ROOT_ENV), CURRENT)
+ link := filepath.Join(os.Getenv(RootEnv), CurrentWorkspace)
newLink := link + ".new"
fi, err := os.Lstat(newLink)
if err == nil {
@@ -561,13 +561,13 @@
}
func (i *invoker) updateNodeManager() error {
- envelope, err := fetchEnvelope(os.Getenv(ORIGIN_ENV))
+ envelope, err := fetchEnvelope(os.Getenv(OriginEnv))
if err != nil {
return err
}
if !reflect.DeepEqual(envelope, i.state.envelope) {
// Create new workspace.
- workspace := filepath.Join(os.Getenv(ROOT_ENV), fmt.Sprintf("%v", time.Now().Format(time.RFC3339Nano)))
+ workspace := filepath.Join(os.Getenv(RootEnv), fmt.Sprintf("%v", time.Now().Format(time.RFC3339Nano)))
perm := os.FileMode(0755)
if err := os.MkdirAll(workspace, perm); err != nil {
vlog.Errorf("MkdirAll(%v, %v) failed: %v", workspace, perm, err)
diff --git a/services/mgmt/node/noded/main.go b/services/mgmt/node/noded/main.go
index 00b6365..d691514 100644
--- a/services/mgmt/node/noded/main.go
+++ b/services/mgmt/node/noded/main.go
@@ -23,8 +23,8 @@
flag.StringVar(&protocol, "protocol", "tcp", "network type to listen on")
flag.StringVar(&publishAs, "name", "", "name to publish the node manager at")
flag.Parse()
- if os.Getenv(impl.ORIGIN_ENV) == "" {
- vlog.Fatalf("Specify the node manager origin as environment variable %s=<name>", impl.ORIGIN_ENV)
+ if os.Getenv(impl.OriginEnv) == "" {
+ vlog.Fatalf("Specify the node manager origin as environment variable %s=<name>", impl.OriginEnv)
}
runtime := rt.Init()
defer runtime.Shutdown()
@@ -40,9 +40,9 @@
suffix, envelope := "", &application.Envelope{}
name := naming.MakeTerminal(naming.JoinAddressName(endpoint.String(), suffix))
vlog.VI(0).Infof("Node manager name: %v", name)
- // TODO(jsimsa): Replace PREVIOUS_ENV with a command-line flag when
+ // TODO(jsimsa): Replace <PreviousEnv> with a command-line flag when
// command-line flags are supported in tests.
- dispatcher := impl.NewDispatcher(vflag.NewAuthorizerOrDie(), envelope, name, os.Getenv(impl.PREVIOUS_ENV))
+ dispatcher := impl.NewDispatcher(vflag.NewAuthorizerOrDie(), envelope, name, os.Getenv(impl.PreviousEnv))
if err := server.Register(suffix, dispatcher); err != nil {
vlog.Fatalf("Register(%v, %v) failed: %v", suffix, dispatcher, err)
}