Skip to content

Commit

Permalink
Merge pull request #1682 from timofurrer/variables-raw
Browse files Browse the repository at this point in the history
Implement raw field for instance variables API
  • Loading branch information
svanharmelen committed Apr 5, 2023
2 parents b88a1b2 + 197113e commit 20cdbe7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions instance_variables.go
Expand Up @@ -41,6 +41,7 @@ type InstanceVariable struct {
VariableType VariableTypeValue `json:"variable_type"`
Protected bool `json:"protected"`
Masked bool `json:"masked"`
Raw bool `json:"raw"`
}

func (v InstanceVariable) String() string {
Expand Down Expand Up @@ -107,6 +108,7 @@ type CreateInstanceVariableOptions struct {
VariableType *VariableTypeValue `url:"variable_type,omitempty" json:"variable_type,omitempty"`
Protected *bool `url:"protected,omitempty" json:"protected,omitempty"`
Masked *bool `url:"masked,omitempty" json:"masked,omitempty"`
Raw *bool `url:"raw,omitempty" json:"raw,omitempty"`
}

// CreateVariable creates a new instance level CI variable.
Expand Down Expand Up @@ -140,6 +142,7 @@ type UpdateInstanceVariableOptions struct {
VariableType *VariableTypeValue `url:"variable_type,omitempty" json:"variable_type,omitempty"`
Protected *bool `url:"protected,omitempty" json:"protected,omitempty"`
Masked *bool `url:"masked,omitempty" json:"masked,omitempty"`
Raw *bool `url:"raw,omitempty" json:"raw,omitempty"`
}

// UpdateVariable updates the position of an existing
Expand Down
16 changes: 12 additions & 4 deletions instance_variables_test.go
Expand Up @@ -20,7 +20,8 @@ func TestInstanceVariablesService_ListVariables(t *testing.T) {
"variable_type": "env_var",
"value": "TEST_1",
"protected": false,
"masked": false
"masked": false,
"raw": true
}
]
`)
Expand All @@ -32,6 +33,7 @@ func TestInstanceVariablesService_ListVariables(t *testing.T) {
VariableType: "env_var",
Protected: false,
Masked: false,
Raw: true,
}}

ivs, resp, err := client.InstanceVariables.ListVariables(nil)
Expand Down Expand Up @@ -70,7 +72,8 @@ func TestInstanceVariablesService_GetVariable(t *testing.T) {
"variable_type": "env_var",
"value": "TEST_1",
"protected": false,
"masked": false
"masked": false,
"raw": true
}
`)
})
Expand All @@ -81,6 +84,7 @@ func TestInstanceVariablesService_GetVariable(t *testing.T) {
VariableType: "env_var",
Protected: false,
Masked: false,
Raw: true,
}

iv, resp, err := client.InstanceVariables.GetVariable("TEST_VARIABLE_1", nil)
Expand Down Expand Up @@ -110,7 +114,8 @@ func TestInstanceVariablesService_CreateVariable(t *testing.T) {
"value": "new value",
"variable_type": "env_var",
"protected": false,
"masked": false
"masked": false,
"raw": true
}
`)
})
Expand All @@ -121,6 +126,7 @@ func TestInstanceVariablesService_CreateVariable(t *testing.T) {
VariableType: "env_var",
Protected: false,
Masked: false,
Raw: true,
}

iv, resp, err := client.InstanceVariables.CreateVariable(nil)
Expand Down Expand Up @@ -159,7 +165,8 @@ func TestInstanceVariablesService_UpdateVariable(t *testing.T) {
"value": "updated value",
"variable_type": "env_var",
"protected": false,
"masked": false
"masked": false,
"raw": true
}
`)
})
Expand All @@ -170,6 +177,7 @@ func TestInstanceVariablesService_UpdateVariable(t *testing.T) {
VariableType: "env_var",
Protected: false,
Masked: false,
Raw: true,
}

iv, resp, err := client.InstanceVariables.UpdateVariable("NEW_VARIABLE", nil)
Expand Down

0 comments on commit 20cdbe7

Please sign in to comment.