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

Commit 6c05c53

Browse files
authored
Merge pull request #2025 from timofurrer/environment-description
Add Description field in Environments API
2 parents 49a7d19 + 0d8687e commit 6c05c53

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

environments.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type Environment struct {
3737
ID int `json:"id"`
3838
Name string `json:"name"`
3939
Slug string `json:"slug"`
40+
Description string `json:"description"`
4041
State string `json:"state"`
4142
Tier string `json:"tier"`
4243
ExternalURL string `json:"external_url"`
@@ -121,6 +122,7 @@ func (s *EnvironmentsService) GetEnvironment(pid interface{}, environment int, o
121122
// https://docs.gitlab.com/ee/api/environments.html#create-a-new-environment
122123
type CreateEnvironmentOptions struct {
123124
Name *string `url:"name,omitempty" json:"name,omitempty"`
125+
Description *string `url:"description,omitempty" json:"description,omitempty"`
124126
ExternalURL *string `url:"external_url,omitempty" json:"external_url,omitempty"`
125127
Tier *string `url:"tier,omitempty" json:"tier,omitempty"`
126128
ClusterAgentID *int `url:"cluster_agent_id,omitempty" json:"cluster_agent_id,omitempty"`
@@ -162,6 +164,7 @@ func (s *EnvironmentsService) CreateEnvironment(pid interface{}, opt *CreateEnvi
162164
// https://docs.gitlab.com/ee/api/environments.html#update-an-existing-environment
163165
type EditEnvironmentOptions struct {
164166
Name *string `url:"name,omitempty" json:"name,omitempty"`
167+
Description *string `url:"description,omitempty" json:"description,omitempty"`
165168
ExternalURL *string `url:"external_url,omitempty" json:"external_url,omitempty"`
166169
Tier *string `url:"tier,omitempty" json:"tier,omitempty"`
167170
ClusterAgentID *int `url:"cluster_agent_id,omitempty" json:"cluster_agent_id,omitempty"`

environments_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func TestListEnvironments(t *testing.T) {
3838
{
3939
"id": 1,
4040
"name": "review/fix-foo",
41+
"description": "test",
4142
"slug": "review-fix-foo-dfjre3",
4243
"external_url": "https://review-fix-foo-dfjre3.example.gitlab.com",
4344
"state": "stopped",
@@ -75,6 +76,7 @@ func TestListEnvironments(t *testing.T) {
7576
ID: 1,
7677
Name: "review/fix-foo",
7778
Slug: "review-fix-foo-dfjre3",
79+
Description: "test",
7880
ExternalURL: "https://review-fix-foo-dfjre3.example.gitlab.com",
7981
State: "stopped",
8082
CreatedAt: &createdAtWant,
@@ -109,6 +111,7 @@ func TestGetEnvironment(t *testing.T) {
109111
fmt.Fprint(w, `{
110112
"id": 1,
111113
"name": "review/fix-foo",
114+
"description": "test",
112115
"slug": "review-fix-foo-dfjre3",
113116
"external_url": "https://review-fix-foo-dfjre3.example.gitlab.com",
114117
"state": "stopped",
@@ -145,6 +148,7 @@ func TestGetEnvironment(t *testing.T) {
145148
ID: 1,
146149
Name: "review/fix-foo",
147150
Slug: "review-fix-foo-dfjre3",
151+
Description: "test",
148152
ExternalURL: "https://review-fix-foo-dfjre3.example.gitlab.com",
149153
State: "stopped",
150154
CreatedAt: &createdAtWant,
@@ -180,6 +184,7 @@ func TestCreateEnvironment(t *testing.T) {
180184
fmt.Fprint(w, `{
181185
"id": 1,
182186
"name": "deploy",
187+
"description": "test",
183188
"slug": "deploy",
184189
"external_url": "https://deploy.example.gitlab.com",
185190
"tier": "production",
@@ -205,6 +210,7 @@ func TestCreateEnvironment(t *testing.T) {
205210

206211
envs, _, err := client.Environments.CreateEnvironment(1, &CreateEnvironmentOptions{
207212
Name: Ptr("deploy"),
213+
Description: Ptr("test"),
208214
ExternalURL: Ptr("https://deploy.example.gitlab.com"),
209215
Tier: Ptr("production"),
210216
ClusterAgentID: Ptr(1),
@@ -220,6 +226,7 @@ func TestCreateEnvironment(t *testing.T) {
220226
ID: 1,
221227
Name: "deploy",
222228
Slug: "deploy",
229+
Description: "test",
223230
ExternalURL: "https://deploy.example.gitlab.com",
224231
Tier: "production",
225232
ClusterAgent: &Agent{
@@ -253,6 +260,7 @@ func TestEditEnvironment(t *testing.T) {
253260
fmt.Fprint(w, `{
254261
"id": 1,
255262
"name": "staging",
263+
"description": "test",
256264
"slug": "staging",
257265
"external_url": "https://staging.example.gitlab.com",
258266
"tier": "staging",
@@ -278,6 +286,7 @@ func TestEditEnvironment(t *testing.T) {
278286

279287
envs, _, err := client.Environments.EditEnvironment(1, 1, &EditEnvironmentOptions{
280288
Name: Ptr("staging"),
289+
Description: Ptr("test"),
281290
ExternalURL: Ptr("https://staging.example.gitlab.com"),
282291
Tier: Ptr("staging"),
283292
ClusterAgentID: Ptr(1),
@@ -293,6 +302,7 @@ func TestEditEnvironment(t *testing.T) {
293302
ID: 1,
294303
Name: "staging",
295304
Slug: "staging",
305+
Description: "test",
296306
ExternalURL: "https://staging.example.gitlab.com",
297307
Tier: "staging",
298308
ClusterAgent: &Agent{
@@ -356,6 +366,7 @@ func TestUnmarshal(t *testing.T) {
356366
{
357367
"id": 10,
358368
"name": "production",
369+
"description": "test",
359370
"slug": "production",
360371
"external_url": "https://example.com",
361372
"project": {
@@ -396,6 +407,7 @@ func TestUnmarshal(t *testing.T) {
396407
if assert.NoError(t, err) {
397408
assert.Equal(t, 10, env.ID)
398409
assert.Equal(t, "production", env.Name)
410+
assert.Equal(t, "test", env.Description)
399411
assert.Equal(t, "https://example.com", env.ExternalURL)
400412
assert.Equal(t, "available", env.State)
401413
if assert.NotNil(t, env.Project) {

0 commit comments

Comments
 (0)