Repository: xanzy/go-gitlab
Pull request #1682 (2023-04-04 12:56:43)

Implement raw field for instance variables API

timofurrer: @svanharmelen do you mind giving this a review and release? 🙏 

Patch:
diff --git a/instance_variables.go b/instance_variables.go
index f196a9c..79b6304 100644
--- a/instance_variables.go
+++ b/instance_variables.go
@@ -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 {
@@ -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.
@@ -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


Test patch:
diff --git a/instance_variables_test.go b/instance_variables_test.go
index cb2b512..05c9e11 100644
--- a/instance_variables_test.go
+++ b/instance_variables_test.go
@@ -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
 				}
 			]
 		`)
@@ -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)
@@ -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
 			}
 		`)
 	})
@@ -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)
@@ -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
 			}
 		`)
 	})
@@ -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)
@@ -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
 			}
 		`)
 	})
@@ -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)