Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Add support for hidden field to group variables #2064

Merged
merged 3 commits into from
Dec 9, 2024
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
2 changes: 2 additions & 0 deletions group_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type GroupVariable struct {
VariableType VariableTypeValue `json:"variable_type"`
Protected bool `json:"protected"`
Masked bool `json:"masked"`
Hidden bool `json:"hidden"`
Raw bool `json:"raw"`
EnvironmentScope string `json:"environment_scope"`
Description string `json:"description"`
Expand Down Expand Up @@ -127,6 +128,7 @@ type CreateGroupVariableOptions struct {
Description *string `url:"description,omitempty" json:"description,omitempty"`
EnvironmentScope *string `url:"environment_scope,omitempty" json:"environment_scope,omitempty"`
Masked *bool `url:"masked,omitempty" json:"masked,omitempty"`
Hidden *bool `url:"hidden,omitempty" json:"hidden,omitempty"`
yogeshlonkar marked this conversation as resolved.
Show resolved Hide resolved
Protected *bool `url:"protected,omitempty" json:"protected,omitempty"`
Raw *bool `url:"raw,omitempty" json:"raw,omitempty"`
VariableType *VariableTypeValue `url:"variable_type,omitempty" json:"variable_type,omitempty"`
Expand Down
16 changes: 9 additions & 7 deletions group_variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestListGroupVariabless(t *testing.T) {
mux.HandleFunc("/api/v4/groups/1/variables",
func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
fmt.Fprint(w, `[{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true}]`)
fmt.Fprint(w, `[{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true,"hidden": true}]`)
})

variables, _, err := client.GroupVariables.ListVariables(1, &ListGroupVariablesOptions{})
Expand All @@ -43,6 +43,7 @@ func TestListGroupVariabless(t *testing.T) {
Value: "test1",
Protected: false,
Masked: true,
Hidden: true,
},
}

Expand All @@ -58,15 +59,15 @@ func TestGetGroupVariable(t *testing.T) {
func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodGet)
testParams(t, r, "filter%5Benvironment_scope%5D=prod")
fmt.Fprint(w, `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true}`)
fmt.Fprint(w, `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true,"hidden": true}`)
})

variable, _, err := client.GroupVariables.GetVariable(1, "TEST_VARIABLE_1", &GetGroupVariableOptions{Filter: &VariableFilter{EnvironmentScope: "prod"}})
if err != nil {
t.Errorf("GroupVariables.GetVariable returned error: %v", err)
}

want := &GroupVariable{Key: "TEST_VARIABLE_1", Value: "test1", Protected: false, Masked: true}
want := &GroupVariable{Key: "TEST_VARIABLE_1", Value: "test1", Protected: false, Masked: true, Hidden: true}
if !reflect.DeepEqual(want, variable) {
t.Errorf("GroupVariables.GetVariable returned %+v, want %+v", variable, want)
}
Expand All @@ -78,22 +79,23 @@ func TestCreateGroupVariable(t *testing.T) {
mux.HandleFunc("/api/v4/groups/1/variables",
func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodPost)
fmt.Fprint(w, `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true}`)
fmt.Fprint(w, `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true,"hidden": true}`)
})

opt := &CreateGroupVariableOptions{
Key: Ptr("TEST_VARIABLE_1"),
Value: Ptr("test1"),
Protected: Ptr(false),
Masked: Ptr(true),
Hidden: Ptr(true),
}

variable, _, err := client.GroupVariables.CreateVariable(1, opt, nil)
if err != nil {
t.Errorf("GroupVariables.CreateVariable returned error: %v", err)
}

want := &GroupVariable{Key: "TEST_VARIABLE_1", Value: "test1", Protected: false, Masked: true}
want := &GroupVariable{Key: "TEST_VARIABLE_1", Value: "test1", Protected: false, Masked: true, Hidden: true}
if !reflect.DeepEqual(want, variable) {
t.Errorf("GroupVariables.CreateVariable returned %+v, want %+v", variable, want)
}
Expand Down Expand Up @@ -126,15 +128,15 @@ func TestUpdateGroupVariable(t *testing.T) {
mux.HandleFunc("/api/v4/groups/1/variables/TEST_VARIABLE_1",
func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, http.MethodPut)
fmt.Fprint(w, `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true}`)
fmt.Fprint(w, `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true,"hidden": false}`)
})

variable, _, err := client.GroupVariables.UpdateVariable(1, "TEST_VARIABLE_1", &UpdateGroupVariableOptions{})
if err != nil {
t.Errorf("GroupVariables.UpdateVariable returned error: %v", err)
}

want := &GroupVariable{Key: "TEST_VARIABLE_1", Value: "test1", Protected: false, Masked: true}
want := &GroupVariable{Key: "TEST_VARIABLE_1", Value: "test1", Protected: false, Masked: true, Hidden: false}
if !reflect.DeepEqual(want, variable) {
t.Errorf("Groups.UpdatedGroup returned %+v, want %+v", variable, want)
}
Expand Down