Skip to content

Commit f2a357b

Browse files
Add .Values method for enums in bundle config tree (#3278)
## Why These methods will be used in #3279 to perform enum validation for their respective fields. ## Tests Generated enum_fields.go file has patterns necessary for validating the fields.
1 parent 8069dc6 commit f2a357b

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

bundle/config/artifact.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ type ArtifactType string
1010

1111
const ArtifactPythonWheel ArtifactType = `whl`
1212

13+
// Values returns all valid ArtifactType values
14+
func (ArtifactType) Values() []ArtifactType {
15+
return []ArtifactType{
16+
ArtifactPythonWheel,
17+
}
18+
}
19+
1320
type ArtifactFile struct {
1421
Source string `json:"source"`
1522

bundle/config/variable/variable.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ const (
1616
VariableTypeComplex VariableType = "complex"
1717
)
1818

19+
// Values returns all valid VariableType values
20+
func (VariableType) Values() []VariableType {
21+
return []VariableType{
22+
VariableTypeComplex,
23+
}
24+
}
25+
1926
// We alias it here to override the JSON schema associated with a variable value
2027
// in a target override. This is because we allow for directly specifying the value
2128
// in addition to the variable.Variable struct format in a target override.

bundle/internal/validation/generated/enum_fields.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/exec/exec.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ const (
1616
CmdExecutable ExecutableType = `cmd`
1717
)
1818

19+
// Values returns all valid ExecutableType values
20+
func (ExecutableType) Values() []ExecutableType {
21+
return []ExecutableType{
22+
BashExecutable,
23+
ShExecutable,
24+
CmdExecutable,
25+
}
26+
}
27+
1928
var finders map[ExecutableType](func() (shell, error)) = map[ExecutableType](func() (shell, error)){
2029
BashExecutable: newBashShell,
2130
ShExecutable: newShShell,

0 commit comments

Comments
 (0)