Skip to content
Snippets Groups Projects
Commit 3c9e07e9 authored by Jessica Yuen's avatar Jessica Yuen
Browse files

Rename environment uri references to server

'server' is consistent with what is used by clientgo. 'uri' only
introduces new language to ksonnet with the same meaning.
parent b70c996f
No related branches found
No related tags found
No related merge requests found
......@@ -28,7 +28,7 @@ import (
const (
flagEnvName = "name"
flagEnvURI = "uri"
flagEnvServer = "server"
flagEnvNamespace = "namespace"
flagEnvContext = "context"
......@@ -49,19 +49,19 @@ func init() {
"Manually specify API version from OpenAPI schema, cluster, or Kubernetes version")
envAddCmd.PersistentFlags().String(flagEnvNamespace, "",
"Specify namespace that the environment cluster should use")
envAddCmd.PersistentFlags().String(flagEnvURI, "",
"Specify the server URI that the environment should use")
envAddCmd.PersistentFlags().String(flagEnvServer, "",
"Specify the address and port of the Kubernetes API server")
envAddCmd.PersistentFlags().String(flagEnvContext, "",
"Specify the context in your kubecfg file that this environment should use")
envSetCmd.PersistentFlags().String(flagEnvName, "",
"Specify name to rename environment to. Name must not already exist")
envSetCmd.PersistentFlags().String(flagEnvURI, "",
"Specify URI to point environment cluster to a new location")
envSetCmd.PersistentFlags().String(flagEnvServer, "",
"Specify the address and port of the Kubernetes API server")
envSetCmd.PersistentFlags().String(flagEnvNamespace, "",
"Specify namespace that the environment cluster should use")
envSetCmd.PersistentFlags().String(flagEnvContext, "",
"Specify the context in your kubecfg file that this environment should use. This will update the server URI for your environment")
"Specify the context in your kubecfg file that this environment should use. This will update the server address for your environment")
}
var envCmd = &cobra.Command{
......@@ -80,7 +80,7 @@ often contained in a kubeconfig file), and
Environments are represented as a hierarchy in the 'environments' directory of a
ksonnet application. For example, in the example below, there are two
environments: 'default' and 'us-west/staging'. Each contains a cached version of
ksonnet-lib, and a 'spec.json' that contains the URI and server cert that
ksonnet-lib, and a 'spec.json' that contains the server and server cert that
uniquely identifies the cluster.
environments/
......@@ -97,7 +97,7 @@ environments/
k.libsonnet
k8s.libsonnet
swagger.json
spec.json [This will contain the uri of the environment and other environment metadata]
spec.json [This will contain the API server address of the environment and other environment metadata]
staging.jsonnet`,
RunE: func(cmd *cobra.Command, args []string) error {
return fmt.Errorf("Command 'env' requires a subcommand\n\n%s", cmd.UsageString())
......@@ -115,7 +115,7 @@ var envAddCmd = &cobra.Command{
name := args[0]
uri, namespace, context, err := commonEnvFlags(flags)
server, namespace, context, err := commonEnvFlags(flags)
if err != nil {
return err
}
......@@ -124,8 +124,8 @@ var envAddCmd = &cobra.Command{
namespace = defaultNamespace
}
if len(uri) == 0 {
// If uri is not provided, use the provided context.
if len(server) == 0 {
// If server is not provided, use the provided context.
// If context is also not provided, use the current context.
var ctx *string
if len(context) != 0 {
......@@ -133,7 +133,7 @@ var envAddCmd = &cobra.Command{
}
var ns string
uri, ns, err = resolveContext(ctx)
server, ns, err = resolveContext(ctx)
if err != nil {
return err
}
......@@ -160,7 +160,7 @@ var envAddCmd = &cobra.Command{
return err
}
c, err := kubecfg.NewEnvAddCmd(name, uri, namespace, specFlag, manager)
c, err := kubecfg.NewEnvAddCmd(name, server, namespace, specFlag, manager)
if err != nil {
return err
}
......@@ -195,7 +195,7 @@ environments/
k.libsonnet
k8s.libsonnet
swagger.json
spec.json [This will contain the uri of the environment and other environment metadata],
spec.json [This will contain the API server address of the environment and other environment metadata],
staging.jsonnet`,
Example: ` # Initialize a new staging environment at 'us-west'.
# The environment will be setup using the current context in your kubecfg file. The directory
......@@ -209,8 +209,8 @@ environments/
# Initialize a new environment using the 'dev' context in your kubeconfig file.
ks env add my-env --context=dev
# Initialize a new environment using a server URI.
ks env add my-env --uri=https://ksonnet-1.us-west.elb.amazonaws.com`,
# Initialize a new environment using a server address.
ks env add my-env --server=https://ksonnet-1.us-west.elb.amazonaws.com`,
}
var envRmCmd = &cobra.Command{
......@@ -279,12 +279,12 @@ var envListCmd = &cobra.Command{
return c.Run(cmd.OutOrStdout())
}, Long: `List all environments in a ksonnet project. This will
display the name, URI, and namespace of each environment within the ksonnet project.`,
display the name, server, and namespace of each environment within the ksonnet project.`,
}
var envSetCmd = &cobra.Command{
Use: "set <env-name>",
Short: "Set environment fields such as the name, cluster URI, and namespace.",
Short: "Set environment fields such as the name, server, and namespace.",
RunE: func(cmd *cobra.Command, args []string) error {
flags := cmd.Flags()
if len(args) != 1 {
......@@ -309,7 +309,7 @@ var envSetCmd = &cobra.Command{
return err
}
uri, namespace, context, err := commonEnvFlags(flags)
server, namespace, context, err := commonEnvFlags(flags)
if err != nil {
return err
}
......@@ -320,39 +320,39 @@ var envSetCmd = &cobra.Command{
}
if len(context) != 0 {
uri, _, err = resolveContext(&context)
server, _, err = resolveContext(&context)
if err != nil {
return err
}
}
c, err := kubecfg.NewEnvSetCmd(originalName, name, uri, namespace, manager)
c, err := kubecfg.NewEnvSetCmd(originalName, name, server, namespace, manager)
if err != nil {
return err
}
return c.Run()
},
Long: `Set environment fields such as the name, and cluster URI. Changing
Long: `Set environment fields such as the name, and server. Changing
the name of an environment will also update the directory structure in
'environments'.`,
Example: ` # Updates the URI of the environment 'us-west/staging'.
ks env set us-west/staging --uri=http://example.com
Example: ` # Updates the API server address of the environment 'us-west/staging'.
ks env set us-west/staging --server=http://example.com
# Updates the namespace of the environment 'us-west/staging'.
ks env set us-west/staging --namespace=staging
# Updates both the name and the URI of the environment 'us-west/staging'.
# Updates both the name and the server of the environment 'us-west/staging'.
# Updating the name will update the directory structure in 'environments'.
ks env set us-west/staging --uri=http://example.com --name=us-east/staging
ks env set us-west/staging --server=http://example.com --name=us-east/staging
# Updates URI of the environment 'us-west/staging' based on the server URI
# in the context 'staging-west' in your kubeconfig file.
# Updates API server address of the environment 'us-west/staging' based on the
# server in the context 'staging-west' in your kubeconfig file.
ks env set us-west/staging --context=staging-west`,
}
func commonEnvFlags(flags *pflag.FlagSet) (uri, namespace, context string, err error) {
uri, err = flags.GetString(flagEnvURI)
func commonEnvFlags(flags *pflag.FlagSet) (server, namespace, context string, err error) {
server, err = flags.GetString(flagEnvServer)
if err != nil {
return "", "", "", err
}
......@@ -367,10 +367,10 @@ func commonEnvFlags(flags *pflag.FlagSet) (uri, namespace, context string, err e
return "", "", "", err
}
if flags.Changed(flagEnvContext) && flags.Changed(flagEnvURI) {
return "", "", "", fmt.Errorf("flags '%s' and '%s' are mutually exclusive, because '%s' has a URI. Try setting '%s', '%s' to the desired values",
flagEnvContext, flagEnvURI, flagEnvContext, flagEnvURI, flagEnvNamespace)
if flags.Changed(flagEnvContext) && flags.Changed(flagEnvServer) {
return "", "", "", fmt.Errorf("flags '%s' and '%s' are mutually exclusive, because '%s' has a server. Try setting '%s', '%s' to the desired values",
flagEnvContext, flagEnvServer, flagEnvContext, flagEnvServer, flagEnvNamespace)
}
return uri, namespace, context, nil
return server, namespace, context, nil
}
......@@ -132,9 +132,9 @@ func namespaceFor(c clientcmd.ClientConfig, overrides clientcmd.ConfigOverrides)
return ns, err
}
// resolveContext returns the server URI and namespace of the cluster at the provided
// resolveContext returns the server and namespace of the cluster at the provided
// context. If context is nil, the current context is used.
func resolveContext(context *string) (uri, namespace string, err error) {
func resolveContext(context *string) (server, namespace string, err error) {
rawConfig, err := clientConfig.RawConfig()
if err != nil {
return "", "", err
......@@ -319,11 +319,11 @@ func parseEnvCmd(cmd *cobra.Command, args []string) (*envSpec, error) {
return &envSpec{env: env, files: files}, nil
}
// overrideCluster ensures that the cluster URI specified in the environment is
// overrideCluster ensures that the server specified in the environment is
// associated in the user's kubeconfig file during deployment to a ksonnet
// environment. We will error out if it is not.
//
// If the environment URI the user is attempting to deploy to is not the current
// If the environment server the user is attempting to deploy to is not the current
// kubeconfig context, we must manually override the client-go --cluster flag
// to ensure we are deploying to the correct cluster.
func overrideCluster(envName string, clientConfig clientcmd.ClientConfig, overrides clientcmd.ConfigOverrides) error {
......@@ -343,24 +343,24 @@ func overrideCluster(envName string, clientConfig clientcmd.ClientConfig, overri
return err
}
var clusterURIs = make(map[string]string)
var servers = make(map[string]string)
for name, cluster := range rawConfig.Clusters {
clusterURIs[cluster.Server] = name
servers[cluster.Server] = name
}
//
// check to ensure that the environment we are trying to deploy to is
// created, and that the environment URI is located in kubeconfig.
// created, and that the server is located in kubeconfig.
//
log.Debugf("Validating deployment at '%s' with cluster URIs '%v'", envName, reflect.ValueOf(clusterURIs).MapKeys())
log.Debugf("Validating deployment at '%s' with server '%v'", envName, reflect.ValueOf(servers).MapKeys())
env, err := metadataManager.GetEnvironment(envName)
if err != nil {
return err
}
if _, ok := clusterURIs[env.URI]; ok {
clusterName := clusterURIs[env.URI]
if _, ok := servers[env.Server]; ok {
clusterName := servers[env.Server]
log.Debugf("Overwriting --cluster flag with '%s'", clusterName)
overrides.Context.Cluster = clusterName
log.Debugf("Overwriting --namespace flag with '%s'", env.Namespace)
......@@ -368,7 +368,7 @@ func overrideCluster(envName string, clientConfig clientcmd.ClientConfig, overri
return nil
}
return fmt.Errorf("Attempting to operate on environment '%s' at %s, but there are no clusters with that URI", envName, env.URI)
return fmt.Errorf("Attempting to deploy to environment '%s' at '%s', but cannot locate a server at that address", envName, env.Server)
}
// expandEnvCmdObjs finds and expands templates for the family of commands of
......
......@@ -45,31 +45,31 @@ const (
type Environment struct {
Path string
Name string
URI string
Server string
Namespace string
}
// EnvironmentSpec represents the contents in spec.json.
type EnvironmentSpec struct {
URI string `json:"uri"`
Server string `json:"server"`
Namespace string `json:"namespace"`
}
func (m *manager) CreateEnvironment(name, uri, namespace string, spec ClusterSpec) error {
func (m *manager) CreateEnvironment(name, server, namespace string, spec ClusterSpec) error {
extensionsLibData, k8sLibData, specData, err := m.generateKsonnetLibData(spec)
if err != nil {
log.Debugf("Failed to write '%s'", specFilename)
return err
}
err = m.createEnvironment(name, uri, namespace, extensionsLibData, k8sLibData, specData)
err = m.createEnvironment(name, server, namespace, extensionsLibData, k8sLibData, specData)
if err == nil {
log.Infof("Environment '%s' pointing to namespace '%s' and cluster at URI '%s' successfully created", name, namespace, uri)
log.Infof("Environment '%s' pointing to namespace '%s' and server address at '%s' successfully created", name, namespace, server)
}
return err
}
func (m *manager) createEnvironment(name, uri, namespace string, extensionsLibData, k8sLibData, specData []byte) error {
func (m *manager) createEnvironment(name, server, namespace string, extensionsLibData, k8sLibData, specData []byte) error {
exists, err := m.environmentExists(name)
if err != nil {
log.Debug("Failed to check whether environment exists")
......@@ -84,7 +84,7 @@ func (m *manager) createEnvironment(name, uri, namespace string, extensionsLibDa
return fmt.Errorf("Environment name '%s' is not valid; must not contain punctuation, spaces, or begin or end with a slash", name)
}
log.Infof("Creating environment '%s' with namespace '%s', pointing at cluster located at uri '%s'", name, namespace, uri)
log.Infof("Creating environment '%s' with namespace '%s', pointing at server at address '%s'", name, namespace, server)
envPath := appendToAbsPath(m.environmentsPath, name)
err = m.appFS.MkdirAll(string(envPath), defaultFolderPermissions)
......@@ -137,7 +137,7 @@ func (m *manager) createEnvironment(name, uri, namespace string, extensionsLibDa
}
// Generate the environment spec file.
envSpecData, err := generateSpecData(uri, namespace)
envSpecData, err := generateSpecData(server, namespace)
if err != nil {
return err
}
......@@ -227,8 +227,8 @@ func (m *manager) GetEnvironments() ([]*Environment, error) {
return err
}
log.Debugf("Found environment '%s', with uri '%s' and namespace '%s'", envName, envSpec.URI, envSpec.Namespace)
envs = append(envs, &Environment{Name: envName, Path: path, URI: envSpec.URI, Namespace: envSpec.Namespace})
log.Debugf("Found environment '%s', with server '%s' and namespace '%s'", envName, envSpec.Server, envSpec.Namespace)
envs = append(envs, &Environment{Name: envName, Path: path, Server: envSpec.Server, Namespace: envSpec.Namespace})
}
}
......@@ -300,12 +300,12 @@ func (m *manager) SetEnvironment(name string, desired *Environment) error {
// Update fields in spec.json.
//
var URI string
if len(desired.URI) != 0 {
log.Infof("Setting environment URI to '%s'", desired.URI)
URI = desired.URI
var server string
if len(desired.Server) != 0 {
log.Infof("Setting environment server to '%s'", desired.Server)
server = desired.Server
} else {
URI = env.URI
server = env.Server
}
var namespace string
if len(desired.Namespace) != 0 {
......@@ -315,9 +315,9 @@ func (m *manager) SetEnvironment(name string, desired *Environment) error {
namespace = env.Namespace
}
newSpec, err := generateSpecData(URI, namespace)
newSpec, err := generateSpecData(server, namespace)
if err != nil {
log.Debugf("Failed to generate %s with URI '%s' and namespace '%s'", specFilename, URI, namespace)
log.Debugf("Failed to generate %s with server '%s' and namespace '%s'", specFilename, server, namespace)
return err
}
......@@ -369,9 +369,9 @@ func (m *manager) generateOverrideData() []byte {
return buf.Bytes()
}
func generateSpecData(uri, namespace string) ([]byte, error) {
func generateSpecData(server, namespace string) ([]byte, error) {
// Format the spec json and return; preface keys with 2 space idents.
return json.MarshalIndent(EnvironmentSpec{URI: uri, Namespace: namespace}, "", " ")
return json.MarshalIndent(EnvironmentSpec{Server: server, Namespace: namespace}, "", " ")
}
func (m *manager) environmentExists(name string) (bool, error) {
......
......@@ -26,15 +26,15 @@ import (
)
const (
mockSpecJSON = "spec.json"
mockSpecJSONURI = "localhost:8080"
mockSpecJSON = "spec.json"
mockSpecJSONServer = "localhost:8080"
mockEnvName = "us-west/test"
mockEnvName2 = "us-west/prod"
mockEnvName3 = "us-east/test"
)
var mockAPIServerURI = "http://google.com"
var mockAPIServer = "http://example.com"
var mockNamespace = "some-namespace"
func mockEnvironments(t *testing.T, appName string) *manager {
......@@ -44,7 +44,7 @@ func mockEnvironments(t *testing.T, appName string) *manager {
}
appPath := AbsPath(appName)
m, err := initManager(appPath, spec, &mockAPIServerURI, &mockNamespace, testFS)
m, err := initManager(appPath, spec, &mockAPIServer, &mockNamespace, testFS)
if err != nil {
t.Fatalf("Failed to init cluster spec: %v", err)
}
......@@ -54,9 +54,9 @@ func mockEnvironments(t *testing.T, appName string) *manager {
envPath := appendToAbsPath(m.environmentsPath, env)
specPath := appendToAbsPath(envPath, mockSpecJSON)
specData, err := generateSpecData(mockSpecJSONURI, mockNamespace)
specData, err := generateSpecData(mockSpecJSONServer, mockNamespace)
if err != nil {
t.Fatalf("Expected to marshal:\nuri: %s\nnamespace: %s\n, but failed", mockSpecJSONURI, mockNamespace)
t.Fatalf("Expected to marshal:\nserver: %s\nnamespace: %s\n, but failed", mockSpecJSONServer, mockNamespace)
}
err = afero.WriteFile(testFS, string(specPath), specData, os.ModePerm)
if err != nil {
......@@ -126,8 +126,8 @@ func TestGetEnvironments(t *testing.T) {
t.Fatalf("Expected to get %d environments, got %d", 4, len(envs))
}
if envs[0].URI != mockSpecJSONURI {
t.Fatalf("Expected env URI to be %s, got %s", mockSpecJSONURI, envs[0].URI)
if envs[0].Server != mockSpecJSONServer {
t.Fatalf("Expected env server to be %s, got %s", mockSpecJSONServer, envs[0].Server)
}
}
......@@ -136,9 +136,9 @@ func TestSetEnvironment(t *testing.T) {
m := mockEnvironments(t, appName)
setName := "new-env"
setURI := "http://example.com"
setServer := "http://example.com"
setNamespace := "some-namespace"
set := Environment{Name: setName, URI: setURI, Namespace: setNamespace}
set := Environment{Name: setName, Server: setServer, Namespace: setNamespace}
// Test updating an environment that doesn't exist
err := m.SetEnvironment("notexists", &set)
......@@ -152,9 +152,9 @@ func TestSetEnvironment(t *testing.T) {
t.Fatalf("Expected error when setting \"%s\" to \"%s\", because env already exists", mockEnvName, mockEnvName2)
}
// Test changing the name and URI of a an existing environment.
// Test changing the name and server of a an existing environment.
// Ensure new env directory is created, and old directory no longer exists.
// Also ensure URI is set in spec.json
// Also ensure server is set in spec.json
err = m.SetEnvironment(mockEnvName, &set)
if err != nil {
t.Fatalf("Could not set \"%s\", got:\n %s", mockEnvName, err)
......@@ -178,11 +178,11 @@ func TestSetEnvironment(t *testing.T) {
if err != nil {
t.Fatalf("Failed to read spec file:\n %s", err)
}
if envSpec.URI != set.URI {
t.Fatalf("Expected set URI to be \"%s\", got:\n %s", set.URI, envSpec.URI)
if envSpec.Server != set.Server {
t.Fatalf("Expected server to be set to '%s', got: '%s'", set.Server, envSpec.Server)
}
if envSpec.Namespace != set.Namespace {
t.Fatalf("Expected set Namespace to be \"%s\", got:\n %s", set.Namespace, envSpec.Namespace)
t.Fatalf("Expected namespace to be set to '%s', got: '%s'", set.Namespace, envSpec.Namespace)
}
}
......
......@@ -60,7 +60,7 @@ func TestInitSuccess(t *testing.T) {
}
appPath := AbsPath("/fromEmptySwagger")
_, err = initManager(appPath, spec, &mockAPIServerURI, &mockNamespace, testFS)
_, err = initManager(appPath, spec, &mockAPIServer, &mockNamespace, testFS)
if err != nil {
t.Fatalf("Failed to init cluster spec: %v", err)
}
......@@ -137,7 +137,7 @@ func TestFindSuccess(t *testing.T) {
}
appPath := AbsPath("/findSuccess")
_, err = initManager(appPath, spec, &mockAPIServerURI, &mockNamespace, testFS)
_, err = initManager(appPath, spec, &mockAPIServer, &mockNamespace, testFS)
if err != nil {
t.Fatalf("Failed to init cluster spec: %v", err)
}
......@@ -165,7 +165,7 @@ func TestComponentPaths(t *testing.T) {
}
appPath := AbsPath("/componentPaths")
m, err := initManager(appPath, spec, &mockAPIServerURI, &mockNamespace, testFS)
m, err := initManager(appPath, spec, &mockAPIServer, &mockNamespace, testFS)
if err != nil {
t.Fatalf("Failed to init cluster spec: %v", err)
}
......@@ -251,13 +251,13 @@ func TestDoubleNewFailure(t *testing.T) {
appPath := AbsPath("/doubleNew")
_, err = initManager(appPath, spec, &mockAPIServerURI, &mockNamespace, testFS)
_, err = initManager(appPath, spec, &mockAPIServer, &mockNamespace, testFS)
if err != nil {
t.Fatalf("Failed to init cluster spec: %v", err)
}
targetErr := fmt.Sprintf("Could not create app; directory '%s' already exists", appPath)
_, err = initManager(appPath, spec, &mockAPIServerURI, &mockNamespace, testFS)
_, err = initManager(appPath, spec, &mockAPIServer, &mockNamespace, testFS)
if err == nil || err.Error() != targetErr {
t.Fatalf("Expected to fail to create app with message '%s', got '%s'", targetErr, err.Error())
}
......
......@@ -28,25 +28,25 @@ import (
type EnvAddCmd struct {
name string
uri string
server string
namespace string
spec metadata.ClusterSpec
manager metadata.Manager
}
func NewEnvAddCmd(name, uri, namespace, specFlag string, manager metadata.Manager) (*EnvAddCmd, error) {
func NewEnvAddCmd(name, server, namespace, specFlag string, manager metadata.Manager) (*EnvAddCmd, error) {
spec, err := metadata.ParseClusterSpec(specFlag)
if err != nil {
return nil, err
}
log.Debugf("Generating ksonnetLib data with spec: %s", specFlag)
return &EnvAddCmd{name: name, uri: uri, namespace: namespace, spec: spec, manager: manager}, nil
return &EnvAddCmd{name: name, server: server, namespace: namespace, spec: spec, manager: manager}, nil
}
func (c *EnvAddCmd) Run() error {
return c.manager.CreateEnvironment(c.name, c.uri, c.namespace, c.spec)
return c.manager.CreateEnvironment(c.name, c.server, c.namespace, c.spec)
}
// ==================================================================
......@@ -79,7 +79,7 @@ func (c *EnvListCmd) Run(out io.Writer) error {
const (
nameHeader = "NAME"
namespaceHeader = "NAMESPACE"
uriHeader = "URI"
serverHeader = "SERVER"
)
envs, err := c.manager.GetEnvironments()
......@@ -93,7 +93,7 @@ func (c *EnvListCmd) Run(out io.Writer) error {
// Format each environment information for pretty printing.
// Each environment should be outputted like the following:
//
// NAME NAMESPACE URI
// NAME NAMESPACE SERVER
// minikube dev localhost:8080
// us-west/staging staging http://example.com
//
......@@ -118,12 +118,12 @@ func (c *EnvListCmd) Run(out io.Writer) error {
headerNameSpacing := strings.Repeat(" ", maxNameLen-len(nameHeader)+1)
headerNamespaceSpacing := strings.Repeat(" ", maxNamespaceLen-maxNameLen-len(namespaceHeader))
lines = append(lines, nameHeader+headerNameSpacing+namespaceHeader+headerNamespaceSpacing+uriHeader+"\n")
lines = append(lines, nameHeader+headerNameSpacing+namespaceHeader+headerNamespaceSpacing+serverHeader+"\n")
for _, env := range envs {
nameSpacing := strings.Repeat(" ", maxNameLen-len(env.Name)+1)
namespaceSpacing := strings.Repeat(" ", maxNamespaceLen-maxNameLen-len(env.Namespace))
lines = append(lines, env.Name+nameSpacing+env.Namespace+namespaceSpacing+env.URI+"\n")
lines = append(lines, env.Name+nameSpacing+env.Namespace+namespaceSpacing+env.Server+"\n")
}
formattedEnvsList := strings.Join(lines, "")
......@@ -138,18 +138,18 @@ type EnvSetCmd struct {
name string
desiredName string
desiredURI string
desiredServer string
desiredNamespace string
manager metadata.Manager
}
func NewEnvSetCmd(name, desiredName, desiredURI, desiredNamespace string, manager metadata.Manager) (*EnvSetCmd, error) {
return &EnvSetCmd{name: name, desiredName: desiredName, desiredURI: desiredURI, desiredNamespace: desiredNamespace,
func NewEnvSetCmd(name, desiredName, desiredServer, desiredNamespace string, manager metadata.Manager) (*EnvSetCmd, error) {
return &EnvSetCmd{name: name, desiredName: desiredName, desiredServer: desiredServer, desiredNamespace: desiredNamespace,
manager: manager}, nil
}
func (c *EnvSetCmd) Run() error {
desired := metadata.Environment{Name: c.desiredName, URI: c.desiredURI, Namespace: c.desiredNamespace}
desired := metadata.Environment{Name: c.desiredName, Server: c.desiredServer, Namespace: c.desiredNamespace}
return c.manager.SetEnvironment(c.name, &desired)
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment