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

Commit

Permalink
Add Description field in Environments API
Browse files Browse the repository at this point in the history
  • Loading branch information
timofurrer committed Oct 8, 2024
1 parent 49a7d19 commit 54388e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions environments.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type EnvironmentsService struct {
type Environment struct {
ID int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Slug string `json:"slug"`
State string `json:"state"`
Tier string `json:"tier"`
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 @@ -74,6 +75,7 @@ func TestListEnvironments(t *testing.T) {
want := []*Environment{{
ID: 1,
Name: "review/fix-foo",
Description: "test",
Slug: "review-fix-foo-dfjre3",
ExternalURL: "https://review-fix-foo-dfjre3.example.gitlab.com",
State: "stopped",
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 @@ -144,6 +147,7 @@ func TestGetEnvironment(t *testing.T) {
want := &Environment{
ID: 1,
Name: "review/fix-foo",
Description: "test",
Slug: "review-fix-foo-dfjre3",
ExternalURL: "https://review-fix-foo-dfjre3.example.gitlab.com",
State: "stopped",
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 @@ -219,6 +225,7 @@ func TestCreateEnvironment(t *testing.T) {
want := &Environment{
ID: 1,
Name: "deploy",
Description: "test",
Slug: "deploy",
ExternalURL: "https://deploy.example.gitlab.com",
Tier: "production",
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 @@ -292,6 +301,7 @@ func TestEditEnvironment(t *testing.T) {
want := &Environment{
ID: 1,
Name: "staging",
Description: "test",
Slug: "staging",
ExternalURL: "https://staging.example.gitlab.com",
Tier: "staging",
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

0 comments on commit 54388e5

Please sign in to comment.