Skip to content

chore: color value_source for deployment values #9922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use nil for secret types
  • Loading branch information
Emyrk committed Sep 29, 2023
commit 1afa4fe47e43394a19d568e7a99088089bfe2320
13 changes: 10 additions & 3 deletions cli/clibase/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"regexp"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/coder/coder/v2/cli/clibase"
Expand Down Expand Up @@ -211,6 +212,8 @@ func TestOptionSet_JsonMarshal(t *testing.T) {
t.Parallel()

t.Run("RegexCase", func(t *testing.T) {
t.Parallel()

val := clibase.Regexp(*regexp.MustCompile(".*"))
opts := clibase.OptionSet{
clibase.Option{
Expand Down Expand Up @@ -282,6 +285,8 @@ func TestOptionSet_JsonMarshal(t *testing.T) {
}

func compareOptions(t *testing.T, exp, found clibase.Option) {
t.Helper()

require.Equalf(t, exp.Name, found.Name, "option name %q", exp.Name)
require.Equalf(t, exp.Description, found.Description, "option description %q", exp.Name)
require.Equalf(t, exp.Required, found.Required, "option required %q", exp.Name)
Expand All @@ -301,7 +306,9 @@ func compareOptions(t *testing.T, exp, found clibase.Option) {
}

func compareValues(t *testing.T, exp, found clibase.Option) {
if exp.Value.String() != found.Value.String() && found.Value.String() == "" {
t.Helper()

if (exp.Value == nil || found.Value == nil) || (exp.Value.String() != found.Value.String() && found.Value.String() == "") {
// If the string values are different, this can be a "nil" issue.
// So only run this case if the found string is the empty string.
// We use MarshalYAML for struct strings, and it will return an
Expand All @@ -315,9 +322,9 @@ func compareValues(t *testing.T, exp, found clibase.Option) {

expJson = normalizeJSON(expJson)
foundJson = normalizeJSON(foundJson)
require.Equalf(t, string(expJson), string(foundJson), "option value %q", exp.Name)
assert.Equalf(t, string(expJson), string(foundJson), "option value %q", exp.Name)
} else {
require.Equal(t,
assert.Equal(t,
exp.Value.String(),
found.Value.String(),
"option value %q", exp.Name)
Expand Down
9 changes: 1 addition & 8 deletions codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -1768,14 +1768,7 @@ func DeploymentOptionsWithoutSecrets(set clibase.OptionSet) clibase.OptionSet {
for _, opt := range set {
cpyOpt := opt
if IsSecretDeploymentOption(cpyOpt) {
switch cpyOpt.Value.Type() {
case "string-array":
var empty clibase.StringArray
cpyOpt.Value = &empty
default:
var empty clibase.String
cpyOpt.Value = &empty
}
cpyOpt.Value = nil
}
cpy = append(cpy, cpyOpt)
}
Expand Down