Skip to content

Commit

Permalink
Merge pull request #67 from ninech/fix-env-removal
Browse files Browse the repository at this point in the history
fix: panic during env removal
  • Loading branch information
ctrox authored Oct 31, 2023
2 parents 8307017 + db8f956 commit 6a20c17
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion update/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (cmd *applicationCmd) applyUpdates(app *apps.Application) {
}

var buildDelEnv []string
if cmd.DeleteEnv != nil {
if cmd.DeleteBuildEnv != nil {
buildDelEnv = *cmd.DeleteBuildEnv
}
app.Spec.ForProvider.BuildEnv = util.UpdateEnvVars(app.Spec.ForProvider.BuildEnv, buildEnv, buildDelEnv)
Expand Down
18 changes: 14 additions & 4 deletions update/application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,26 @@ func TestApplication(t *testing.T) {
assert.Nil(t, util.EnvVarByName(updated.Spec.ForProvider.BuildEnv, BuildTrigger))
},
},
"reset env variables": {
"reset env variable": {
orig: existingApp,
cmd: applicationCmd{
Name: pointer.String(existingApp.Name),
DeleteEnv: &[]string{"foo"},
},
checkApp: func(t *testing.T, cmd applicationCmd, orig, updated *apps.Application) {
assert.Empty(t, updated.Spec.ForProvider.Config.Env)
assert.NotEmpty(t, updated.Spec.ForProvider.BuildEnv)
},
},
"reset build env variable": {
orig: existingApp,
cmd: applicationCmd{
Name: pointer.String(existingApp.Name),
DeleteEnv: &[]string{"foo"},
DeleteBuildEnv: &[]string{"BP_ENVIRONMENT_VARIABLE"},
},
checkApp: func(t *testing.T, cmd applicationCmd, orig, updated *apps.Application) {
assert.Equal(t, apps.EnvVars{}, updated.Spec.ForProvider.Config.Env)
assert.Equal(t, apps.EnvVars{}, updated.Spec.ForProvider.BuildEnv)
assert.Empty(t, updated.Spec.ForProvider.BuildEnv)
assert.NotEmpty(t, updated.Spec.ForProvider.Config.Env)
},
},
"git auth update user/pass": {
Expand Down

0 comments on commit 6a20c17

Please sign in to comment.