Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
go-gitlab
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
go-gitlab
Commits
9a26b9c5
Commit
9a26b9c5
authored
Feb 04, 2019
by
Matej Velikonja
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix some style issues
parent
08f71cd0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
40 deletions
+38
-40
project_clusters.go
project_clusters.go
+38
-40
No files found.
project_clusters.go
View file @
9a26b9c5
...
@@ -36,17 +36,16 @@ type ProjectClustersService struct {
...
@@ -36,17 +36,16 @@ type ProjectClustersService struct {
// GitLab API docs:
// GitLab API docs:
// https://docs.gitlab.com/ee/api/project_clusters.html
// https://docs.gitlab.com/ee/api/project_clusters.html
type
ProjectCluster
struct
{
type
ProjectCluster
struct
{
ID
int
`json:"id,omitempty"`
ID
int
`json:"id"`
Name
string
`json:"name,omitempty"`
Name
string
`json:"name"`
Enabled
*
bool
`json:"enabled,omitempty"`
CreatedAt
*
time
.
Time
`json:"created_at"`
CreatedAt
*
time
.
Time
`json:"created_at,omitempty"`
ProviderType
string
`json:"provider_type"`
ProviderType
string
`json:"provider_type,omitempty"`
PlatformType
string
`json:"platform_type"`
PlatformType
string
`json:"platform_type,omitempty"`
EnvironmentScope
string
`json:"environment_scope"`
EnvironmentScope
string
`json:"environment_scope,omitempty"`
ClusterType
string
`json:"cluster_type"`
ClusterType
string
`json:"cluster_type,omitempty"`
User
*
User
`json:"user"`
User
*
User
`json:"user,omitempty"`
PlatformKubernetes
*
PlatformKubernetes
`json:"platform_kubernetes"`
PlatformKubernetes
PlatformKubernetes
`json:"platform_kubernetes,omitempty"`
Project
*
Project
`json:"project"`
Project
*
Project
`json:"project,omitempty"`
}
}
func
(
v
ProjectCluster
)
String
()
string
{
func
(
v
ProjectCluster
)
String
()
string
{
...
@@ -55,11 +54,11 @@ func (v ProjectCluster) String() string {
...
@@ -55,11 +54,11 @@ func (v ProjectCluster) String() string {
// PlatformKubernetes represents a GitLab Project Cluster PlatformKubernetes.
// PlatformKubernetes represents a GitLab Project Cluster PlatformKubernetes.
type
PlatformKubernetes
struct
{
type
PlatformKubernetes
struct
{
APIURL
string
`json:"api_url
,omitempty
"`
APIURL
string
`json:"api_url"`
Token
string
`json:"token
,omitempty
"`
Token
string
`json:"token"`
CaCert
string
`json:"ca_cert
,omitempty
"`
CaCert
string
`json:"ca_cert"`
Namespace
string
`json:"namespace
,omitempty
"`
Namespace
string
`json:"namespace"`
AuthorizationType
string
`json:"authorization_type
,omitempty
"`
AuthorizationType
string
`json:"authorization_type"`
}
}
// ListClusters gets a list of all clusters in a project.
// ListClusters gets a list of all clusters in a project.
...
@@ -67,49 +66,49 @@ type PlatformKubernetes struct {
...
@@ -67,49 +66,49 @@ type PlatformKubernetes struct {
// GitLab API docs:
// GitLab API docs:
// https://docs.gitlab.com/ee/api/project_clusters.html#list-project-clusters
// https://docs.gitlab.com/ee/api/project_clusters.html#list-project-clusters
func
(
s
*
ProjectClustersService
)
ListClusters
(
pid
interface
{},
options
...
OptionFunc
)
([]
*
ProjectCluster
,
*
Response
,
error
)
{
func
(
s
*
ProjectClustersService
)
ListClusters
(
pid
interface
{},
options
...
OptionFunc
)
([]
*
ProjectCluster
,
*
Response
,
error
)
{
project
ID
,
err
:=
parseID
(
pid
)
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
u
:=
fmt
.
Sprintf
(
"projects/%s/clusters"
,
url
.
QueryEscape
(
project
ID
))
u
:=
fmt
.
Sprintf
(
"projects/%s/clusters"
,
url
.
QueryEscape
(
project
))
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
,
options
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
var
vs
[]
*
ProjectCluster
var
pc
[]
*
ProjectCluster
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
vs
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
pc
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
resp
,
err
return
nil
,
resp
,
err
}
}
return
vs
,
resp
,
err
return
pc
,
resp
,
err
}
}
// GetCluster gets a cluster.
// GetCluster gets a cluster.
//
//
// GitLab API docs:
// GitLab API docs:
// https://docs.gitlab.com/ee/api/project_clusters.html#get-a-single-project-cluster
// https://docs.gitlab.com/ee/api/project_clusters.html#get-a-single-project-cluster
func
(
s
*
ProjectClustersService
)
GetCluster
(
pid
interface
{},
cluster
ID
int
,
options
...
OptionFunc
)
(
*
ProjectCluster
,
*
Response
,
error
)
{
func
(
s
*
ProjectClustersService
)
GetCluster
(
pid
interface
{},
cluster
int
,
options
...
OptionFunc
)
(
*
ProjectCluster
,
*
Response
,
error
)
{
project
ID
,
err
:=
parseID
(
pid
)
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
u
:=
fmt
.
Sprintf
(
"projects/%s/clusters/%d"
,
url
.
QueryEscape
(
project
ID
),
clusterID
)
u
:=
fmt
.
Sprintf
(
"projects/%s/clusters/%d"
,
url
.
QueryEscape
(
project
),
cluster
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
,
options
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
var
vs
*
ProjectCluster
var
pc
*
ProjectCluster
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
vs
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
pc
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
resp
,
err
return
nil
,
resp
,
err
}
}
return
vs
,
resp
,
err
return
pc
,
resp
,
err
}
}
// AddClusterOptions represents the available AddCluster() options.
// AddClusterOptions represents the available AddCluster() options.
...
@@ -117,10 +116,10 @@ func (s *ProjectClustersService) GetCluster(pid interface{}, clusterID int, opti
...
@@ -117,10 +116,10 @@ func (s *ProjectClustersService) GetCluster(pid interface{}, clusterID int, opti
// GitLab API docs:
// GitLab API docs:
// https://docs.gitlab.com/ee/api/project_clusters.html#add-existing-cluster-to-project
// https://docs.gitlab.com/ee/api/project_clusters.html#add-existing-cluster-to-project
type
AddClusterOptions
struct
{
type
AddClusterOptions
struct
{
Name
string
`json:"name,omitempty"`
Name
string
`json:"name,omitempty"`
Enabled
*
bool
`json:"enabled,omitempty"`
Enabled
*
bool
`json:"enabled,omitempty"`
EnvironmentScope
string
`json:"environment_scope,omitempty"`
EnvironmentScope
string
`json:"environment_scope,omitempty"`
PlatformKubernetes
PlatformKubernetes
`json:"platform_kubernetes_attributes,omitempty"`
PlatformKubernetes
*
PlatformKubernetes
`json:"platform_kubernetes_attributes,omitempty"`
}
}
// AddCluster adds an existing cluster to the project.
// AddCluster adds an existing cluster to the project.
...
@@ -138,8 +137,7 @@ func (s *ProjectClustersService) AddCluster(pid interface{}, opt *AddClusterOpti
...
@@ -138,8 +137,7 @@ func (s *ProjectClustersService) AddCluster(pid interface{}, opt *AddClusterOpti
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
//b, _ := ioutil.ReadAll(req.Body)
//fmt.Println(string(b))
pc
:=
new
(
ProjectCluster
)
pc
:=
new
(
ProjectCluster
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
pc
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
pc
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -154,21 +152,21 @@ func (s *ProjectClustersService) AddCluster(pid interface{}, opt *AddClusterOpti
...
@@ -154,21 +152,21 @@ func (s *ProjectClustersService) AddCluster(pid interface{}, opt *AddClusterOpti
// GitLab API docs:
// GitLab API docs:
// https://docs.gitlab.com/ee/api/project_clusters.html#edit-project-cluster
// https://docs.gitlab.com/ee/api/project_clusters.html#edit-project-cluster
type
EditClusterOptions
struct
{
type
EditClusterOptions
struct
{
Name
string
`json:"name"`
Name
string
`json:"name"`
EnvironmentScope
string
`json:"environment_scope,omitempty"`
EnvironmentScope
string
`json:"environment_scope,omitempty"`
PlatformKubernetes
PlatformKubernetes
`json:"platform_kubernetes_attributes,omitempty"`
PlatformKubernetes
*
PlatformKubernetes
`json:"platform_kubernetes_attributes,omitempty"`
}
}
// EditCluster updates an existing project cluster.
// EditCluster updates an existing project cluster.
//
//
// GitLab API docs:
// GitLab API docs:
// https://docs.gitlab.com/ee/api/project_clusters.html#edit-project-cluster
// https://docs.gitlab.com/ee/api/project_clusters.html#edit-project-cluster
func
(
s
*
ProjectClustersService
)
EditCluster
(
pid
interface
{},
c
id
int
,
opt
*
EditClusterOptions
,
options
...
OptionFunc
)
(
*
ProjectCluster
,
*
Response
,
error
)
{
func
(
s
*
ProjectClustersService
)
EditCluster
(
pid
interface
{},
c
luster
int
,
opt
*
EditClusterOptions
,
options
...
OptionFunc
)
(
*
ProjectCluster
,
*
Response
,
error
)
{
project
,
err
:=
parseID
(
pid
)
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
u
:=
fmt
.
Sprintf
(
"projects/%s/clusters/%d"
,
url
.
QueryEscape
(
project
),
c
id
)
u
:=
fmt
.
Sprintf
(
"projects/%s/clusters/%d"
,
url
.
QueryEscape
(
project
),
c
luster
)
req
,
err
:=
s
.
client
.
NewRequest
(
"PUT"
,
u
,
opt
,
options
)
req
,
err
:=
s
.
client
.
NewRequest
(
"PUT"
,
u
,
opt
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -188,12 +186,12 @@ func (s *ProjectClustersService) EditCluster(pid interface{}, cid int, opt *Edit
...
@@ -188,12 +186,12 @@ func (s *ProjectClustersService) EditCluster(pid interface{}, cid int, opt *Edit
//
//
// GitLab API docs:
// GitLab API docs:
// https://docs.gitlab.com/ee/api/project_clusters.html#delete-project-cluster
// https://docs.gitlab.com/ee/api/project_clusters.html#delete-project-cluster
func
(
s
*
ProjectClustersService
)
DeleteCluster
(
pid
interface
{},
c
id
int
,
options
...
OptionFunc
)
(
*
Response
,
error
)
{
func
(
s
*
ProjectClustersService
)
DeleteCluster
(
pid
interface
{},
c
luster
int
,
options
...
OptionFunc
)
(
*
Response
,
error
)
{
project
,
err
:=
parseID
(
pid
)
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
u
:=
fmt
.
Sprintf
(
"projects/%s/clusters/%d"
,
url
.
QueryEscape
(
project
),
c
id
)
u
:=
fmt
.
Sprintf
(
"projects/%s/clusters/%d"
,
url
.
QueryEscape
(
project
),
c
luster
)
req
,
err
:=
s
.
client
.
NewRequest
(
"DELETE"
,
u
,
nil
,
options
)
req
,
err
:=
s
.
client
.
NewRequest
(
"DELETE"
,
u
,
nil
,
options
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment