Commit a019cf82 authored by Oren Shomron's avatar Oren Shomron
Browse files

Rename EnvironmentSpec[s] -> EnvironmentConfig[s]


Signed-off-by: default avatarOren Shomron <shomron@gmail.com>
parent d44b841c
......@@ -28,7 +28,7 @@ func TestEnvDescribe(t *testing.T) {
withApp(t, func(appMock *amocks.App) {
envName := "default"
env := &app.EnvironmentSpec{
env := &app.EnvironmentConfig{
KubernetesVersion: "v1.7.0",
}
......
......@@ -29,14 +29,14 @@ import (
func TestEnvList(t *testing.T) {
withApp(t, func(appMock *amocks.App) {
env := &app.EnvironmentSpec{
env := &app.EnvironmentConfig{
KubernetesVersion: "v1.7.0",
Destination: &app.EnvironmentDestinationSpec{
Namespace: "default",
Server: "http://example.com",
},
}
envs := app.EnvironmentSpecs{
envs := app.EnvironmentConfigs{
"default": env,
}
......
......@@ -50,7 +50,7 @@ func RunEnvSet(m map[string]interface{}) error {
// func types for renaming and updating environments
type envRenameFn func(a app.App, from, to string, override bool) error
type updateEnvFn func(a app.App, envName, k8sAPISpec string, spec *app.EnvironmentSpec, override bool) error
type updateEnvFn func(a app.App, envName, k8sAPISpec string, spec *app.EnvironmentConfig, override bool) error
// EnvSet sets targets for an environment.
type EnvSet struct {
......@@ -99,7 +99,7 @@ func (es *EnvSet) Run() error {
return err
}
if err := es.updateEnvSpec(env); err != nil {
if err := es.updateEnvConfig(env); err != nil {
return err
}
......@@ -118,7 +118,7 @@ func (es *EnvSet) updateName(isOverride bool) error {
return nil
}
func (es *EnvSet) updateEnvSpec(env *app.EnvironmentSpec) error {
func (es *EnvSet) updateEnvConfig(env *app.EnvironmentConfig) error {
if es.newNsName == "" && es.newServer == "" && es.newAPISpec == "" {
return nil
}
......@@ -134,6 +134,6 @@ func (es *EnvSet) updateEnvSpec(env *app.EnvironmentSpec) error {
return es.updateEnvFn(es.app, es.envName, es.newAPISpec, env, env.IsOverride())
}
func updateEnv(a app.App, envName, k8sAPISpec string, spec *app.EnvironmentSpec, override bool) error {
return a.AddEnvironment(envName, k8sAPISpec, spec, override)
func updateEnv(a app.App, envName, k8sAPISpec string, env *app.EnvironmentConfig, override bool) error {
return a.AddEnvironment(envName, k8sAPISpec, env, override)
}
......@@ -33,8 +33,8 @@ func TestEnvSet(t *testing.T) {
server := "new_server"
newk8sAPISpec := "version:new_api_spec"
environmentMockFn := func(name string) *app.EnvironmentSpec {
return &app.EnvironmentSpec{
environmentMockFn := func(name string) *app.EnvironmentConfig {
return &app.EnvironmentConfig{
Destination: &app.EnvironmentDestinationSpec{
Namespace: oldNamespace,
Server: oldServer,
......@@ -46,7 +46,7 @@ func TestEnvSet(t *testing.T) {
cases := []struct {
name string
in map[string]interface{}
spec *app.EnvironmentSpec
spec *app.EnvironmentConfig
envRenameFn func(t *testing.T) envRenameFn
updateEnvFn func(t *testing.T) updateEnvFn
}{
......@@ -75,8 +75,8 @@ func TestEnvSet(t *testing.T) {
OptionNamespace: namespace,
},
updateEnvFn: func(t *testing.T) updateEnvFn {
return func(a app.App, envName, k8sAPISpec string, spec *app.EnvironmentSpec, override bool) error {
assert.Equal(t, spec, &app.EnvironmentSpec{
return func(a app.App, envName, k8sAPISpec string, spec *app.EnvironmentConfig, override bool) error {
assert.Equal(t, spec, &app.EnvironmentConfig{
Destination: &app.EnvironmentDestinationSpec{
Namespace: namespace,
Server: oldServer,
......@@ -94,8 +94,8 @@ func TestEnvSet(t *testing.T) {
OptionServer: server,
},
updateEnvFn: func(t *testing.T) updateEnvFn {
return func(a app.App, envName, k8sAPISpec string, spec *app.EnvironmentSpec, override bool) error {
assert.Equal(t, spec, &app.EnvironmentSpec{
return func(a app.App, envName, k8sAPISpec string, spec *app.EnvironmentConfig, override bool) error {
assert.Equal(t, spec, &app.EnvironmentConfig{
Destination: &app.EnvironmentDestinationSpec{
Namespace: oldNamespace,
Server: server,
......@@ -113,7 +113,7 @@ func TestEnvSet(t *testing.T) {
OptionSpecFlag: newk8sAPISpec,
},
updateEnvFn: func(t *testing.T) updateEnvFn {
return func(a app.App, envName, k8sAPISpec string, spec *app.EnvironmentSpec, override bool) error {
return func(a app.App, envName, k8sAPISpec string, spec *app.EnvironmentConfig, override bool) error {
assert.Equal(t, newk8sAPISpec, k8sAPISpec)
return nil
}
......@@ -130,8 +130,8 @@ func TestEnvSet(t *testing.T) {
OptionSpecFlag: newk8sAPISpec,
},
updateEnvFn: func(t *testing.T) updateEnvFn {
return func(a app.App, newName, k8sAPISpec string, spec *app.EnvironmentSpec, override bool) error {
assert.Equal(t, spec, &app.EnvironmentSpec{
return func(a app.App, newName, k8sAPISpec string, spec *app.EnvironmentConfig, override bool) error {
assert.Equal(t, spec, &app.EnvironmentConfig{
Destination: &app.EnvironmentDestinationSpec{
Namespace: namespace,
Server: server,
......
......@@ -32,7 +32,7 @@ func TestEnvTargets(t *testing.T) {
envName := "default"
modules := []string{"foo"}
env := &app.EnvironmentSpec{}
env := &app.EnvironmentConfig{}
appMock.On("Environment", "default").Return(env, nil)
appMock.On("UpdateTargets", envName, modules).Return(nil)
......@@ -62,7 +62,7 @@ func TestEnvTargets_invalid_module(t *testing.T) {
envName := "default"
modules := []string{"foo"}
env := &app.EnvironmentSpec{}
env := &app.EnvironmentConfig{}
appMock.On("Environment", "default").Return(env, nil)
appMock.On("UpdateTargets", envName, modules).Return(nil)
......@@ -92,7 +92,7 @@ func TestEnvTargets_invalid_environment(t *testing.T) {
envName := "invalid"
modules := []string{"foo"}
env := &app.EnvironmentSpec{}
env := &app.EnvironmentConfig{}
envErr := errors.New("environment invalid was not found")
appMock.On("Environment", "invalid").Return(env, envErr)
......
......@@ -27,7 +27,7 @@ import (
func TestEnvUpdate(t *testing.T) {
withApp(t, func(appMock *amocks.App) {
envSpec := &app.EnvironmentSpec{
envSpec := &app.EnvironmentConfig{
KubernetesVersion: "v1.8.9",
}
appMock.On("Environment", "envName").Return(envSpec, nil)
......
......@@ -64,7 +64,7 @@ func TestValidate(t *testing.T) {
aModuleName := "module"
aClientConfig := &client.Config{}
env := &app.EnvironmentSpec{}
env := &app.EnvironmentConfig{}
appMock.On("Environment", "default").Return(env, nil)
in := map[string]interface{}{
......
......@@ -56,15 +56,15 @@ var (
// App is a ksonnet application.
type App interface {
// AddEnvironment adds an environment.
AddEnvironment(name, k8sSpecFlag string, spec *EnvironmentSpec, isOverride bool) error
AddEnvironment(name, k8sSpecFlag string, spec *EnvironmentConfig, isOverride bool) error
// AddRegistry adds a registry.
AddRegistry(spec *RegistryConfig, isOverride bool) error
// CurrentEnvironment returns the current environment name or an empty string.
CurrentEnvironment() string
// Environment finds an environment by name.
Environment(name string) (*EnvironmentSpec, error)
Environment(name string) (*EnvironmentConfig, error)
// Environments returns all environments.
Environments() (EnvironmentSpecs, error)
Environments() (EnvironmentConfigs, error)
// EnvironmentParams returns params for an environment.
EnvironmentParams(name string) (string, error)
// Fs is the app's afero Fs.
......
......@@ -54,7 +54,7 @@ func NewApp001(fs afero.Fs, root string) *App001 {
// AddEnvironment adds an environment spec to the app spec. If the spec already exists,
// it is overwritten.
func (a *App001) AddEnvironment(name, k8sSpecFlag string, spec *EnvironmentSpec, isOverride bool) error {
func (a *App001) AddEnvironment(name, k8sSpecFlag string, spec *EnvironmentConfig, isOverride bool) error {
// if it is an override, write the destination to override file. If not, do the normal thing.
envPath := filepath.Join(a.root, EnvironmentDirName, name)
......@@ -77,21 +77,21 @@ func (a *App001) AddEnvironment(name, k8sSpecFlag string, spec *EnvironmentSpec,
return err
}
func (a *App001) overrideDestintation(name string, envSpec *EnvironmentSpec) error {
func (a *App001) overrideDestintation(name string, envSpec *EnvironmentConfig) error {
return nil
}
// Environment returns the spec for an environment. In 0.1.0, the file lives in
// /environments/name/spec.json.
func (a *App001) Environment(name string) (*EnvironmentSpec, error) {
func (a *App001) Environment(name string) (*EnvironmentConfig, error) {
path := filepath.Join(a.root, EnvironmentDirName, name, app001specJSON)
return read001EnvSpec(a.fs, name, path)
}
// Environments returns specs for all environments. In 0.1.0, the environment spec
// lives in spec.json files.
func (a *App001) Environments() (EnvironmentSpecs, error) {
specs := EnvironmentSpecs{}
func (a *App001) Environments() (EnvironmentConfigs, error) {
specs := EnvironmentConfigs{}
root := filepath.Join(a.root, EnvironmentDirName)
......@@ -222,7 +222,7 @@ type k8sSchema struct {
} `json:"info,omitempty"`
}
func read001EnvSpec(fs afero.Fs, name, path string) (*EnvironmentSpec, error) {
func read001EnvSpec(fs afero.Fs, name, path string) (*EnvironmentConfig, error) {
b, err := afero.ReadFile(fs, path)
if err != nil {
return nil, err
......@@ -254,7 +254,7 @@ func read001EnvSpec(fs afero.Fs, name, path string) (*EnvironmentSpec, error) {
return nil, errors.New("unable to determine environment Kubernetes version")
}
spec := EnvironmentSpec{
spec := EnvironmentConfig{
Path: name,
Destination: &s,
KubernetesVersion: ks.Info.Version,
......
......@@ -89,8 +89,8 @@ func TestApp001_RenameEnvironment(t *testing.T) {
func TestApp001_Environments(t *testing.T) {
withApp001Fs(t, "app001_app.yaml", func(app *App001) {
expected := EnvironmentSpecs{
"default": &EnvironmentSpec{
expected := EnvironmentConfigs{
"default": &EnvironmentConfig{
Destination: &EnvironmentDestinationSpec{
Namespace: "some-namespace",
Server: "http://example.com",
......@@ -98,7 +98,7 @@ func TestApp001_Environments(t *testing.T) {
KubernetesVersion: "v1.7.0",
Path: "default",
},
"us-east/test": &EnvironmentSpec{
"us-east/test": &EnvironmentConfig{
Destination: &EnvironmentDestinationSpec{
Namespace: "some-namespace",
Server: "http://example.com",
......@@ -106,7 +106,7 @@ func TestApp001_Environments(t *testing.T) {
KubernetesVersion: "v1.7.0",
Path: "us-east/test",
},
"us-west/test": &EnvironmentSpec{
"us-west/test": &EnvironmentConfig{
Destination: &EnvironmentDestinationSpec{
Namespace: "some-namespace",
Server: "http://example.com",
......@@ -114,7 +114,7 @@ func TestApp001_Environments(t *testing.T) {
KubernetesVersion: "v1.7.0",
Path: "us-west/test",
},
"us-west/prod": &EnvironmentSpec{
"us-west/prod": &EnvironmentConfig{
Destination: &EnvironmentDestinationSpec{
Namespace: "some-namespace",
Server: "http://example.com",
......@@ -164,7 +164,7 @@ func TestApp001_Environment(t *testing.T) {
func TestApp001_AddEnvironment(t *testing.T) {
withApp001Fs(t, "app001_app.yaml", func(app *App001) {
newEnv := &EnvironmentSpec{
newEnv := &EnvironmentConfig{
Destination: &EnvironmentDestinationSpec{
Namespace: "some-namespace",
Server: "http://example.com",
......
......@@ -48,7 +48,7 @@ func NewApp010(fs afero.Fs, root string) *App010 {
// AddEnvironment adds an environment spec to the app spec. If the spec already exists,
// it is overwritten.
func (a *App010) AddEnvironment(name, k8sSpecFlag string, newEnv *EnvironmentSpec, isOverride bool) error {
func (a *App010) AddEnvironment(name, k8sSpecFlag string, newEnv *EnvironmentConfig, isOverride bool) error {
logrus.WithFields(logrus.Fields{
"k8s-spec-flag": k8sSpecFlag,
"name": name,
......@@ -79,7 +79,7 @@ func (a *App010) AddEnvironment(name, k8sSpecFlag string, newEnv *EnvironmentSpe
}
// Environment returns the spec for an environment.
func (a *App010) Environment(name string) (*EnvironmentSpec, error) {
func (a *App010) Environment(name string) (*EnvironmentConfig, error) {
if err := a.load(); err != nil {
return nil, errors.Wrap(err, "load configuration")
}
......@@ -100,12 +100,12 @@ func (a *App010) Environment(name string) (*EnvironmentSpec, error) {
}
// Environments returns all environment specs.
func (a *App010) Environments() (EnvironmentSpecs, error) {
func (a *App010) Environments() (EnvironmentConfigs, error) {
if err := a.load(); err != nil {
return nil, errors.Wrap(err, "load configuration")
}
environments := EnvironmentSpecs{}
environments := EnvironmentConfigs{}
for k, v := range a.config.Environments {
environments[k] = v
}
......
......@@ -33,7 +33,7 @@ func TestApp010_AddEnvironment(t *testing.T) {
envLen := len(envs)
newEnv := &EnvironmentSpec{
newEnv := &EnvironmentConfig{
Destination: &EnvironmentDestinationSpec{
Namespace: "some-namespace",
Server: "http://example.com",
......@@ -83,8 +83,9 @@ func TestApp010_AddEnvironment_empty_spec_flag(t *testing.T) {
func TestApp0101_Environments(t *testing.T) {
withApp010Fs(t, "app010_app.yaml", func(app *App010) {
expected := EnvironmentSpecs{
"default": &EnvironmentSpec{
expected := EnvironmentConfigs{
"default": &EnvironmentConfig{
Name: "default",
Destination: &EnvironmentDestinationSpec{
Namespace: "some-namespace",
Server: "http://example.com",
......@@ -92,7 +93,8 @@ func TestApp0101_Environments(t *testing.T) {
KubernetesVersion: "v1.7.0",
Path: "default",
},
"us-east/test": &EnvironmentSpec{
"us-east/test": &EnvironmentConfig{
Name: "us-east/test",
Destination: &EnvironmentDestinationSpec{
Namespace: "some-namespace",
Server: "http://example.com",
......@@ -100,7 +102,8 @@ func TestApp0101_Environments(t *testing.T) {
KubernetesVersion: "v1.7.0",
Path: "us-east/test",
},
"us-west/test": &EnvironmentSpec{
"us-west/test": &EnvironmentConfig{
Name: "us-west/test",
Destination: &EnvironmentDestinationSpec{
Namespace: "some-namespace",
Server: "http://example.com",
......@@ -108,7 +111,8 @@ func TestApp0101_Environments(t *testing.T) {
KubernetesVersion: "v1.7.0",
Path: "us-west/test",
},
"us-west/prod": &EnvironmentSpec{
"us-west/prod": &EnvironmentConfig{
Name: "us-west/prod",
Destination: &EnvironmentDestinationSpec{
Namespace: "some-namespace",
Server: "http://example.com",
......
......@@ -40,7 +40,7 @@ func newBaseApp(fs afero.Fs, root string) *baseApp {
root: root,
config: &Spec{},
overrides: &Override{
Environments: EnvironmentSpecs{},
Environments: EnvironmentConfigs{},
Registries: RegistryConfigs{},
},
}
......@@ -113,7 +113,7 @@ func (ba *baseApp) load() error {
}
if len(config.Environments) == 0 {
config.Environments = EnvironmentSpecs{}
config.Environments = EnvironmentConfigs{}
}
if len(config.Registries) == 0 {
......@@ -121,7 +121,7 @@ func (ba *baseApp) load() error {
}
override := Override{
Environments: EnvironmentSpecs{},
Environments: EnvironmentConfigs{},
Registries: RegistryConfigs{},
}
if exists {
......@@ -138,7 +138,7 @@ func (ba *baseApp) load() error {
}
if len(override.Environments) == 0 {
override.Environments = EnvironmentSpecs{}
override.Environments = EnvironmentConfigs{}
}
if len(override.Registries) == 0 {
......
......@@ -26,11 +26,11 @@ type App struct {
}
// AddEnvironment provides a mock function with given fields: name, k8sSpecFlag, spec, isOverride
func (_m *App) AddEnvironment(name string, k8sSpecFlag string, spec *app.EnvironmentSpec, isOverride bool) error {
func (_m *App) AddEnvironment(name string, k8sSpecFlag string, spec *app.EnvironmentConfig, isOverride bool) error {
ret := _m.Called(name, k8sSpecFlag, spec, isOverride)
var r0 error
if rf, ok := ret.Get(0).(func(string, string, *app.EnvironmentSpec, bool) error); ok {
if rf, ok := ret.Get(0).(func(string, string, *app.EnvironmentConfig, bool) error); ok {
r0 = rf(name, k8sSpecFlag, spec, isOverride)
} else {
r0 = ret.Error(0)
......@@ -68,15 +68,15 @@ func (_m *App) CurrentEnvironment() string {
}
// Environment provides a mock function with given fields: name
func (_m *App) Environment(name string) (*app.EnvironmentSpec, error) {
func (_m *App) Environment(name string) (*app.EnvironmentConfig, error) {
ret := _m.Called(name)
var r0 *app.EnvironmentSpec
if rf, ok := ret.Get(0).(func(string) *app.EnvironmentSpec); ok {
var r0 *app.EnvironmentConfig
if rf, ok := ret.Get(0).(func(string) *app.EnvironmentConfig); ok {
r0 = rf(name)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*app.EnvironmentSpec)
r0 = ret.Get(0).(*app.EnvironmentConfig)
}
}
......@@ -112,15 +112,15 @@ func (_m *App) EnvironmentParams(name string) (string, error) {
}
// Environments provides a mock function with given fields:
func (_m *App) Environments() (app.EnvironmentSpecs, error) {
func (_m *App) Environments() (app.EnvironmentConfigs, error) {
ret := _m.Called()
var r0 app.EnvironmentSpecs
if rf, ok := ret.Get(0).(func() app.EnvironmentSpecs); ok {
var r0 app.EnvironmentConfigs
if rf, ok := ret.Get(0).(func() app.EnvironmentConfigs); ok {
r0 = rf()
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(app.EnvironmentSpecs)
r0 = ret.Get(0).(app.EnvironmentConfigs)
}
}
......
......@@ -33,7 +33,7 @@ const (
type Override struct {
Kind string `json:"kind"`
APIVersion string `json:"apiVersion"`
Environments EnvironmentSpecs `json:"environments,omitempty"`
Environments EnvironmentConfigs `json:"environments,omitempty"`
Registries RegistryConfigs `json:"registries,omitempty"`
}
......
......@@ -63,7 +63,7 @@ type Spec struct {
Bugs string `json:"bugs,omitempty"`
Keywords []string `json:"keywords,omitempty"`
Registries RegistryConfigs `json:"registries,omitempty"`
Environments EnvironmentSpecs `json:"environments,omitempty"`
Environments EnvironmentConfigs `json:"environments,omitempty"`
Libraries LibraryConfigs `json:"libraries,omitempty"`
License string `json:"license,omitempty"`
}
......@@ -130,7 +130,7 @@ func write(fs afero.Fs, appRoot string, spec *Spec) error {
o := Override{
Kind: overrideKind,
APIVersion: overrideVersion,
Environments: EnvironmentSpecs{},
Environments: EnvironmentConfigs{},
Registries: RegistryConfigs{},
}
......@@ -248,11 +248,29 @@ func (r *RegistryConfigs) UnmarshalJSON(b []byte) error {
return nil
}
// EnvironmentSpecs contains one or more EnvironmentSpec.
type EnvironmentSpecs map[string]*EnvironmentSpec
// EnvironmentConfigs contains one or more EnvironmentConfig.
type EnvironmentConfigs map[string]*EnvironmentConfig
// EnvironmentSpec contains the specification for ksonnet environments.
type EnvironmentSpec struct {
// UnmarshalJSON implements the json.Unmarshaler interface.
// Our goal is to populate the Name field of EnvironmentConfig
// objects according to they key name in the environments map.
func (e *EnvironmentConfigs) UnmarshalJSON(b []byte) error {
envs := make(map[string]*EnvironmentConfig)
if err := json.Unmarshal(b, &envs); err != nil {
return err
}
// Set Name fields according to map keys
for k, v := range envs {
v.Name = k
}
*e = EnvironmentConfigs(envs)
return nil
}
// EnvironmentConfig contains the specification for ksonnet environments.
type EnvironmentConfig struct {
// Name is the user defined name of an environment
Name string `json:"-"`
// KubernetesVersion is the kubernetes version the targeted cluster is
......@@ -271,15 +289,15 @@ type EnvironmentSpec struct {
}
// MakePath return the absolute path to the environment directory.
func (e *EnvironmentSpec) MakePath(rootPath string) string {
func (e *EnvironmentConfig) MakePath(rootPath string) string {
return filepath.Join(
rootPath,
EnvironmentDirName,
filepath.FromSlash(e.Path))
}
// IsOverride is true if this EnvironmentSpec is an override.
func (e *EnvironmentSpec) IsOverride() bool {
// IsOverride is true if this EnvironmentConfig is an override.
func (e *EnvironmentConfig) IsOverride() bool {
return e.isOverride
}
......@@ -338,16 +356,16 @@ func (s *Spec) RegistryConfig(name string) (*RegistryConfig, bool) {
}
// AddRegistryConfig adds the RegistryConfig to the app spec.
func (s *Spec) AddRegistryConfig(RegistryConfig *RegistryConfig) error {
if RegistryConfig.Name == "" {
func (s *Spec) AddRegistryConfig(cfg *RegistryConfig) error {
if cfg.Name == "" {
return ErrRegistryNameInvalid
}
if _, exists := s.Registries[RegistryConfig.Name]; exists {
if _, exists := s.Registries[cfg.Name]; exists {
return ErrRegistryExists
}
s.Registries[RegistryConfig.Name] = RegistryConfig
s.Registries[cfg.Name] = cfg
return nil
}
......@@ -365,7 +383,7 @@ func (s *Spec) validate() error {
}
if s.Environments == nil {
s.Environments = EnvironmentSpecs{}
s.Environments = EnvironmentConfigs{}
}
if s.APIVersion == "0.0.0" {
......@@ -388,9 +406,9 @@ func (s *Spec) validate() error {
return nil
}
// GetEnvironmentSpecs returns all environment specifications.
// We need to pre-populate th EnvironmentSpec name before returning.
func (s *Spec) GetEnvironmentSpecs() EnvironmentSpecs {
// GetEnvironmentConfigs returns all environment specifications.
// TODO: Consider returning copies instead of originals
func (s *Spec) GetEnvironmentConfigs() EnvironmentConfigs {
for k, v := range s.Environments {
v.Name = k
}
......@@ -398,55 +416,55 @@ func (s *Spec) GetEnvironmentSpecs() EnvironmentSpecs {
return s.Environments
}
// GetEnvironmentSpec returns the environment specification for the environment.
func (s *Spec) GetEnvironmentSpec(name string) (*EnvironmentSpec, bool) {
environmentSpec, ok := s.Environments[name]
// GetEnvironmentConfig returns the environment specification for the environment.
// TODO: Consider returning copies instead of originals
func (s *Spec) GetEnvironmentConfig(name string) (*EnvironmentConfig, bool) {
env, ok := s.Environments[name]
if ok {
environmentSpec.Name = name
env.Name = name
}
return environmentSpec, ok
return env, ok
}
// AddEnvironmentSpec adds an EnvironmentSpec to the list of EnvironmentSpecs.
// AddEnvironmentConfig adds an EnvironmentConfig to the list of EnvironmentConfigs.
// This is equivalent to registering the environment for a ksonnet app.
func (s *Spec) AddEnvironmentSpec(spec *EnvironmentSpec) error {
if spec.Name == "" {
func (s *Spec) AddEnvironmentConfig(env *EnvironmentConfig) error {
if env.Name == "" {
return ErrEnvironmentNameInvalid
}
_, environmentSpecExists := s.Environments[spec.Name]