Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
golang-gitlab-gitlab-org-api-client-go
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Debian Go Packaging Team
packages
golang-gitlab-gitlab-org-api-client-go
Commits
3a152ef5
Commit
3a152ef5
authored
6 years ago
by
Ilan Shamir
Browse files
Options
Downloads
Patches
Plain Diff
implemneted get environment
parent
e4d31990
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
environments.go
+30
-4
30 additions, 4 deletions
environments.go
environments_test.go
+20
-0
20 additions, 0 deletions
environments_test.go
with
50 additions
and
4 deletions
environments.go
+
30
−
4
View file @
3a152ef5
...
...
@@ -36,6 +36,7 @@ type Environment struct {
Name
string
`json:"name"`
Slug
string
`json:"slug"`
ExternalURL
string
`json:"external_url"`
LastDeployment
Deployment
`json:"last_deployment,omitempty"`
}
func
(
env
Environment
)
String
()
string
{
...
...
@@ -74,6 +75,31 @@ func (s *EnvironmentsService) ListEnvironments(pid interface{}, opts *ListEnviro
return
envs
,
resp
,
err
}
// GetEnvironment gets a specific environment from a project
//
// GitLab API docs:
// https://docs.gitlab.com/ee/api/environments.html#get-a-specific-environment
func
(
s
*
EnvironmentsService
)
GetEnvironment
(
pid
interface
{},
environment
int
,
options
...
OptionFunc
)
(
*
Environment
,
*
Response
,
error
)
{
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/environments/%d"
,
pathEscape
(
project
),
environment
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
env
:=
new
(
Environment
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
env
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
env
,
resp
,
err
}
// CreateEnvironmentOptions represents the available CreateEnvironment() options.
//
// GitLab API docs:
...
...
This diff is collapsed.
Click to expand it.
environments_test.go
+
20
−
0
View file @
3a152ef5
...
...
@@ -29,6 +29,26 @@ func TestListEnvironments(t *testing.T) {
}
}
func
TestGetEnvironment
(
t
*
testing
.
T
)
{
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/api/v4/projects/1/environments/5949167"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"GET"
)
fmt
.
Fprint
(
w
,
`{"id":1,"name":"test/test"}`
)
})
env
,
_
,
err
:=
client
.
Environments
.
GetEnvironment
(
1
,
5949167
)
if
err
!=
nil
{
t
.
Errorf
(
"Environemtns.GetEnvironment returned error: %v"
,
err
)
}
want
:=
&
Environment
{
ID
:
1
,
Name
:
"test/test"
}
if
!
reflect
.
DeepEqual
(
want
,
env
)
{
t
.
Errorf
(
"Environments.GetEnvironment returned %+v, want %+v"
,
env
,
want
)
}
}
func
TestCreateEnvironment
(
t
*
testing
.
T
)
{
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment