Skip to content
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
update golden files
  • Loading branch information
Emyrk committed Jan 16, 2024
commit 0ef1e621e9a5aab0b7cbdc441dc66ac08163b107
22 changes: 22 additions & 0 deletions cli/clibase/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,28 @@ func (i *Validator[T]) Type() string {
return i.Value.Type()
}

func (u *Validator[T]) MarshalYAML() (interface{}, error) {
m, ok := any(u.Value).(yaml.Marshaler)
if !ok {
return u.Value, nil
}
return m.MarshalYAML()
}

func (u *Validator[T]) UnmarshalYAML(n *yaml.Node) error {
return n.Decode(u.Value)
}

func (u *Validator[T]) MarshalJSON() ([]byte, error) {
return json.Marshal(u.Value)
}

func (u *Validator[T]) UnmarshalJSON(b []byte) error {
return json.Unmarshal(b, u.Value)
}

func (*Validator[T]) IsValidator() {}

// values.go contains a standard set of value types that can be used as
// Option Values.

Expand Down
6 changes: 5 additions & 1 deletion cli/clibase/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,17 @@ func (optSet *OptionSet) MarshalYAML() (any, error) {
Value: opt.YAML,
HeadComment: comment,
}

_, isValidator := opt.Value.(interface{ IsValidator() })

var valueNode yaml.Node
if opt.Value == nil {
valueNode = yaml.Node{
Kind: yaml.ScalarNode,
Value: "null",
}
} else if m, ok := opt.Value.(yaml.Marshaler); ok {
} else if m, ok := opt.Value.(yaml.Marshaler); ok && !isValidator {
// Validators do a wrap, and should be handled by the else statement.
v, err := m.MarshalYAML()
if err != nil {
return nil, xerrors.Errorf(
Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/coder_server_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ NETWORKING OPTIONS:
--secure-auth-cookie bool, $CODER_SECURE_AUTH_COOKIE
Controls if the 'Secure' property is set on browser session cookies.

--wildcard-access-url url, $CODER_WILDCARD_ACCESS_URL
--wildcard-access-url string, $CODER_WILDCARD_ACCESS_URL
Specifies the wildcard hostname to use for workspace applications in
the form "*.example.com".

Expand Down
4 changes: 2 additions & 2 deletions cli/testdata/server-config.yaml.golden
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ networking:
accessURL:
# Specifies the wildcard hostname to use for workspace applications in the form
# "*.example.com".
# (default: <unset>, type: url)
wildcardAccessURL:
# (default: <unset>, type: string)
wildcardAccessURL: ""
# Specifies the custom docs URL.
# (default: <unset>, type: url)
docsURL:
Expand Down
2 changes: 1 addition & 1 deletion enterprise/cli/testdata/coder_server_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ NETWORKING OPTIONS:
--secure-auth-cookie bool, $CODER_SECURE_AUTH_COOKIE
Controls if the 'Secure' property is set on browser session cookies.

--wildcard-access-url url, $CODER_WILDCARD_ACCESS_URL
--wildcard-access-url string, $CODER_WILDCARD_ACCESS_URL
Specifies the wildcard hostname to use for workspace applications in
the form "*.example.com".

Expand Down