Skip to content

Commit

Permalink
Use *VarFileFormat pointer as per API conventions
Browse files Browse the repository at this point in the history
Signed-off-by: Yury Tsarev <yury.tsarev@absa.africa>
  • Loading branch information
ytsarev committed Jan 20, 2022
1 parent 1dae613 commit a5ff90d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apis/v1alpha1/workspace_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const (
type VarFileFormat string

// Vars file formats.
const (
var (
VarFileFormatHCL VarFileFormat = "HCL"
VarFileFormatJSON VarFileFormat = "JSON"
)
Expand All @@ -56,7 +56,7 @@ type VarFile struct {
// Format of this vars file.
// +kubebuilder:default=HCL
// +optional
Format VarFileFormat `json:"format"`
Format *VarFileFormat `json:"format,omitempty"`

// A ConfigMap key containing the vars file.
// +optional
Expand Down
5 changes: 5 additions & 0 deletions apis/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/controller/workspace/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func (c *external) options(ctx context.Context, p v1alpha1.WorkspaceParameters)

for _, vf := range p.VarFiles {
fmt := terraform.HCL
if vf.Format == v1alpha1.VarFileFormatJSON {
if vf.Format == &v1alpha1.VarFileFormatJSON {
fmt = terraform.JSON
}

Expand Down
4 changes: 2 additions & 2 deletions internal/controller/workspace/workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ func TestCreate(t *testing.T) {
{
Source: v1alpha1.VarFileSourceSecretKey,
SecretKeyReference: &v1alpha1.KeyReference{},
Format: v1alpha1.VarFileFormatJSON,
Format: &v1alpha1.VarFileFormatJSON,
},
},
},
Expand Down Expand Up @@ -975,7 +975,7 @@ func TestDelete(t *testing.T) {
{
Source: v1alpha1.VarFileSourceSecretKey,
SecretKeyReference: &v1alpha1.KeyReference{},
Format: v1alpha1.VarFileFormatJSON,
Format: &v1alpha1.VarFileFormatJSON,
},
},
},
Expand Down

0 comments on commit a5ff90d

Please sign in to comment.