Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Description field in Environments API #2025

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Environment struct {
ID int `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
Description string `json:"description"`
State string `json:"state"`
Tier string `json:"tier"`
ExternalURL string `json:"external_url"`
Expand Down Expand Up @@ -121,6 +122,7 @@ func (s *EnvironmentsService) GetEnvironment(pid interface{}, environment int, o
// https://docs.gitlab.com/ee/api/environments.html#create-a-new-environment
type CreateEnvironmentOptions struct {
Name *string `url:"name,omitempty" json:"name,omitempty"`
Description *string `url:"description,omitempty" json:"description,omitempty"`
ExternalURL *string `url:"external_url,omitempty" json:"external_url,omitempty"`
Tier *string `url:"tier,omitempty" json:"tier,omitempty"`
ClusterAgentID *int `url:"cluster_agent_id,omitempty" json:"cluster_agent_id,omitempty"`
Expand Down Expand Up @@ -162,6 +164,7 @@ func (s *EnvironmentsService) CreateEnvironment(pid interface{}, opt *CreateEnvi
// https://docs.gitlab.com/ee/api/environments.html#update-an-existing-environment
type EditEnvironmentOptions struct {
Name *string `url:"name,omitempty" json:"name,omitempty"`
Description *string `url:"description,omitempty" json:"description,omitempty"`
ExternalURL *string `url:"external_url,omitempty" json:"external_url,omitempty"`
Tier *string `url:"tier,omitempty" json:"tier,omitempty"`
ClusterAgentID *int `url:"cluster_agent_id,omitempty" json:"cluster_agent_id,omitempty"`
Expand Down
12 changes: 12 additions & 0 deletions environments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func TestListEnvironments(t *testing.T) {
{
"id": 1,
"name": "review/fix-foo",
"description": "test",
"slug": "review-fix-foo-dfjre3",
"external_url": "https://review-fix-foo-dfjre3.example.gitlab.com",
"state": "stopped",
Expand Down Expand Up @@ -75,6 +76,7 @@ func TestListEnvironments(t *testing.T) {
ID: 1,
Name: "review/fix-foo",
Slug: "review-fix-foo-dfjre3",
Description: "test",
ExternalURL: "https://review-fix-foo-dfjre3.example.gitlab.com",
State: "stopped",
CreatedAt: &createdAtWant,
Expand Down Expand Up @@ -109,6 +111,7 @@ func TestGetEnvironment(t *testing.T) {
fmt.Fprint(w, `{
"id": 1,
"name": "review/fix-foo",
"description": "test",
"slug": "review-fix-foo-dfjre3",
"external_url": "https://review-fix-foo-dfjre3.example.gitlab.com",
"state": "stopped",
Expand Down Expand Up @@ -145,6 +148,7 @@ func TestGetEnvironment(t *testing.T) {
ID: 1,
Name: "review/fix-foo",
Slug: "review-fix-foo-dfjre3",
Description: "test",
ExternalURL: "https://review-fix-foo-dfjre3.example.gitlab.com",
State: "stopped",
CreatedAt: &createdAtWant,
Expand Down Expand Up @@ -180,6 +184,7 @@ func TestCreateEnvironment(t *testing.T) {
fmt.Fprint(w, `{
"id": 1,
"name": "deploy",
"description": "test",
"slug": "deploy",
"external_url": "https://deploy.example.gitlab.com",
"tier": "production",
Expand All @@ -205,6 +210,7 @@ func TestCreateEnvironment(t *testing.T) {

envs, _, err := client.Environments.CreateEnvironment(1, &CreateEnvironmentOptions{
Name: Ptr("deploy"),
Description: Ptr("test"),
ExternalURL: Ptr("https://deploy.example.gitlab.com"),
Tier: Ptr("production"),
ClusterAgentID: Ptr(1),
Expand All @@ -220,6 +226,7 @@ func TestCreateEnvironment(t *testing.T) {
ID: 1,
Name: "deploy",
Slug: "deploy",
Description: "test",
ExternalURL: "https://deploy.example.gitlab.com",
Tier: "production",
ClusterAgent: &Agent{
Expand Down Expand Up @@ -253,6 +260,7 @@ func TestEditEnvironment(t *testing.T) {
fmt.Fprint(w, `{
"id": 1,
"name": "staging",
"description": "test",
"slug": "staging",
"external_url": "https://staging.example.gitlab.com",
"tier": "staging",
Expand All @@ -278,6 +286,7 @@ func TestEditEnvironment(t *testing.T) {

envs, _, err := client.Environments.EditEnvironment(1, 1, &EditEnvironmentOptions{
Name: Ptr("staging"),
Description: Ptr("test"),
ExternalURL: Ptr("https://staging.example.gitlab.com"),
Tier: Ptr("staging"),
ClusterAgentID: Ptr(1),
Expand All @@ -293,6 +302,7 @@ func TestEditEnvironment(t *testing.T) {
ID: 1,
Name: "staging",
Slug: "staging",
Description: "test",
ExternalURL: "https://staging.example.gitlab.com",
Tier: "staging",
ClusterAgent: &Agent{
Expand Down Expand Up @@ -356,6 +366,7 @@ func TestUnmarshal(t *testing.T) {
{
"id": 10,
"name": "production",
"description": "test",
"slug": "production",
"external_url": "https://example.com",
"project": {
Expand Down Expand Up @@ -396,6 +407,7 @@ func TestUnmarshal(t *testing.T) {
if assert.NoError(t, err) {
assert.Equal(t, 10, env.ID)
assert.Equal(t, "production", env.Name)
assert.Equal(t, "test", env.Description)
assert.Equal(t, "https://example.com", env.ExternalURL)
assert.Equal(t, "available", env.State)
if assert.NotNil(t, env.Project) {
Expand Down