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
7537b744
Commit
7537b744
authored
Aug 15, 2019
by
Sander van Harmelen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the now obsolete build variables
parent
7846dae9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
291 deletions
+4
-291
README.md
README.md
+4
-4
build_variables.go
build_variables.go
+0
-172
build_variables_test.go
build_variables_test.go
+0
-113
gitlab.go
gitlab.go
+0
-2
No files found.
README.md
View file @
7537b744
...
...
@@ -20,10 +20,6 @@ incompatible changes that were needed to fully support the V4 Gitlab API.
This API client package covers most of the existing Gitlab API calls and is updated regularly
to add new and/or missing endpoints. Currently the following services are supported:
-
[
]
Discussions (threaded comments)
-
[
]
Epic Issues
-
[
]
Epics
-
[
]
Geo Nodes
-
[
x
]
Award Emojis
-
[
x
]
Branches
-
[
x
]
Broadcast Messages
...
...
@@ -32,9 +28,13 @@ to add new and/or missing endpoints. Currently the following services are suppor
-
[
x
]
Custom Attributes
-
[
x
]
Deploy Keys
-
[
x
]
Deployments
-
[
]
Discussions (threaded comments)
-
[
x
]
Environments
-
[
]
Epic Issues
-
[
]
Epics
-
[
x
]
Events
-
[
x
]
Feature Flags
-
[
]
Geo Nodes
-
[
x
]
GitLab CI Config Templates
-
[
x
]
Gitignores Templates
-
[
x
]
Group Access Requests
...
...
build_variables.go
deleted
100644 → 0
View file @
7846dae9
package
gitlab
import
(
"fmt"
)
// BuildVariablesService handles communication with the project variables related methods
// of the Gitlab API
//
// Gitlab API Docs : https://docs.gitlab.com/ce/api/build_variables.html
type
BuildVariablesService
struct
{
client
*
Client
}
// BuildVariable represents a variable available for each build of the given project
//
// Gitlab API Docs : https://docs.gitlab.com/ce/api/build_variables.html
type
BuildVariable
struct
{
Key
string
`json:"key"`
Value
string
`json:"value"`
Protected
bool
`json:"protected"`
}
func
(
v
BuildVariable
)
String
()
string
{
return
Stringify
(
v
)
}
// ListBuildVariablesOptions are the parameters to ListBuildVariables()
//
// Gitlab API Docs:
// https://docs.gitlab.com/ce/api/build_variables.html#list-project-variables
type
ListBuildVariablesOptions
ListOptions
// ListBuildVariables gets the a list of project variables in a project
//
// Gitlab API Docs:
// https://docs.gitlab.com/ce/api/build_variables.html#list-project-variables
func
(
s
*
BuildVariablesService
)
ListBuildVariables
(
pid
interface
{},
opts
*
ListBuildVariablesOptions
,
options
...
OptionFunc
)
([]
*
BuildVariable
,
*
Response
,
error
)
{
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/variables"
,
pathEscape
(
project
))
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
opts
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
var
v
[]
*
BuildVariable
resp
,
err
:=
s
.
client
.
Do
(
req
,
&
v
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
v
,
resp
,
err
}
// GetBuildVariable gets a single project variable of a project
//
// Gitlab API Docs:
// https://docs.gitlab.com/ce/api/build_variables.html#show-variable-details
func
(
s
*
BuildVariablesService
)
GetBuildVariable
(
pid
interface
{},
key
string
,
options
...
OptionFunc
)
(
*
BuildVariable
,
*
Response
,
error
)
{
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/variables/%s"
,
pathEscape
(
project
),
key
)
req
,
err
:=
s
.
client
.
NewRequest
(
"GET"
,
u
,
nil
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
v
:=
new
(
BuildVariable
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
v
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
v
,
resp
,
err
}
// CreateBuildVariableOptions are the parameters to CreateBuildVariable()
//
// Gitlab API Docs:
// https://docs.gitlab.com/ce/api/build_variables.html#create-variable
type
CreateBuildVariableOptions
struct
{
Key
*
string
`url:"key" json:"key"`
Value
*
string
`url:"value" json:"value"`
Protected
*
bool
`url:"protected,omitempty" json:"protected,omitempty"`
}
// CreateBuildVariable creates a variable for a given project
//
// Gitlab API Docs:
// https://docs.gitlab.com/ce/api/build_variables.html#create-variable
func
(
s
*
BuildVariablesService
)
CreateBuildVariable
(
pid
interface
{},
opt
*
CreateBuildVariableOptions
,
options
...
OptionFunc
)
(
*
BuildVariable
,
*
Response
,
error
)
{
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/variables"
,
pathEscape
(
project
))
req
,
err
:=
s
.
client
.
NewRequest
(
"POST"
,
u
,
opt
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
v
:=
new
(
BuildVariable
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
v
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
v
,
resp
,
err
}
// UpdateBuildVariableOptions are the parameters to UpdateBuildVariable()
//
// Gitlab API Docs:
// https://docs.gitlab.com/ce/api/build_variables.html#update-variable
type
UpdateBuildVariableOptions
struct
{
Key
*
string
`url:"key" json:"key"`
Value
*
string
`url:"value" json:"value"`
Protected
*
bool
`url:"protected,omitempty" json:"protected,omitempty"`
}
// UpdateBuildVariable updates an existing project variable
// The variable key must exist
//
// Gitlab API Docs:
// https://docs.gitlab.com/ce/api/build_variables.html#update-variable
func
(
s
*
BuildVariablesService
)
UpdateBuildVariable
(
pid
interface
{},
key
string
,
opt
*
UpdateBuildVariableOptions
,
options
...
OptionFunc
)
(
*
BuildVariable
,
*
Response
,
error
)
{
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/variables/%s"
,
pathEscape
(
project
),
key
)
req
,
err
:=
s
.
client
.
NewRequest
(
"PUT"
,
u
,
opt
,
options
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
v
:=
new
(
BuildVariable
)
resp
,
err
:=
s
.
client
.
Do
(
req
,
v
)
if
err
!=
nil
{
return
nil
,
resp
,
err
}
return
v
,
resp
,
err
}
// RemoveBuildVariable removes a project variable of a given project identified by its key
//
// Gitlab API Docs:
// https://docs.gitlab.com/ce/api/build_variables.html#remove-variable
func
(
s
*
BuildVariablesService
)
RemoveBuildVariable
(
pid
interface
{},
key
string
,
options
...
OptionFunc
)
(
*
Response
,
error
)
{
project
,
err
:=
parseID
(
pid
)
if
err
!=
nil
{
return
nil
,
err
}
u
:=
fmt
.
Sprintf
(
"projects/%s/variables/%s"
,
pathEscape
(
project
),
key
)
req
,
err
:=
s
.
client
.
NewRequest
(
"DELETE"
,
u
,
nil
,
options
)
if
err
!=
nil
{
return
nil
,
err
}
return
s
.
client
.
Do
(
req
,
nil
)
}
build_variables_test.go
deleted
100644 → 0
View file @
7846dae9
package
gitlab
import
(
"fmt"
"net/http"
"reflect"
"testing"
)
const
(
myKey
=
"MY_KEY"
myValue
=
"MY_VALUE"
myKey2
=
"MY_KEY2"
myValue2
=
"MY_VALUE2"
myNewValue
=
"MY_NEW_VALUE"
)
func
TestListBuildVariables
(
t
*
testing
.
T
)
{
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/api/v4/projects/1/variables"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"GET"
)
fmt
.
Fprintf
(
w
,
`[{"key":"%s","value":"%s"},{"key":"%s","value":"%s"}]`
,
myKey
,
myValue
,
myKey2
,
myValue2
)
})
variables
,
_
,
err
:=
client
.
BuildVariables
.
ListBuildVariables
(
1
,
nil
)
if
err
!=
nil
{
t
.
Errorf
(
"ListBuildVariables returned error: %v"
,
err
)
}
want
:=
[]
*
BuildVariable
{{
Key
:
myKey
,
Value
:
myValue
},
{
Key
:
myKey2
,
Value
:
myValue2
}}
if
!
reflect
.
DeepEqual
(
want
,
variables
)
{
t
.
Errorf
(
"ListBuildVariables returned %+v, want %+v"
,
variables
,
want
)
}
}
func
TestGetBuildVariable
(
t
*
testing
.
T
)
{
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/api/v4/projects/1/variables/"
+
myKey
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"GET"
)
fmt
.
Fprintf
(
w
,
`{"key":"%s","value":"%s"}`
,
myKey
,
myValue
)
})
variable
,
_
,
err
:=
client
.
BuildVariables
.
GetBuildVariable
(
1
,
myKey
)
if
err
!=
nil
{
t
.
Errorf
(
"GetBuildVariable returned error: %v"
,
err
)
}
want
:=
&
BuildVariable
{
Key
:
myKey
,
Value
:
myValue
}
if
!
reflect
.
DeepEqual
(
want
,
variable
)
{
t
.
Errorf
(
"GetBuildVariable returned %+v, want %+v"
,
variable
,
want
)
}
}
func
TestCreateBuildVariable
(
t
*
testing
.
T
)
{
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/api/v4/projects/1/variables"
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"POST"
)
fmt
.
Fprintf
(
w
,
`{"key":"%s","value":"%s", "protected": false}`
,
myKey
,
myValue
)
})
opt
:=
&
CreateBuildVariableOptions
{
String
(
myKey
),
String
(
myValue
),
Bool
(
false
)}
variable
,
_
,
err
:=
client
.
BuildVariables
.
CreateBuildVariable
(
1
,
opt
)
if
err
!=
nil
{
t
.
Errorf
(
"CreateBuildVariable returned error: %v"
,
err
)
}
want
:=
&
BuildVariable
{
Key
:
myKey
,
Value
:
myValue
,
Protected
:
false
}
if
!
reflect
.
DeepEqual
(
want
,
variable
)
{
t
.
Errorf
(
"CreateBuildVariable returned %+v, want %+v"
,
variable
,
want
)
}
}
func
TestUpdateBuildVariable
(
t
*
testing
.
T
)
{
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/api/v4/projects/1/variables/"
+
myKey
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"PUT"
)
fmt
.
Fprintf
(
w
,
`{"key":"%s","value":"%s", "protected": false}`
,
myKey
,
myNewValue
)
})
opt
:=
&
UpdateBuildVariableOptions
{
String
(
myKey
),
String
(
myNewValue
),
Bool
(
false
)}
variable
,
_
,
err
:=
client
.
BuildVariables
.
UpdateBuildVariable
(
1
,
myKey
,
opt
)
if
err
!=
nil
{
t
.
Errorf
(
"UpdateBuildVariable returned error: %v"
,
err
)
}
want
:=
&
BuildVariable
{
Key
:
myKey
,
Value
:
myNewValue
,
Protected
:
false
}
if
!
reflect
.
DeepEqual
(
want
,
variable
)
{
t
.
Errorf
(
"UpdateBuildVariable returned %+v, want %+v"
,
variable
,
want
)
}
}
func
TestRemoveBuildVariable
(
t
*
testing
.
T
)
{
mux
,
server
,
client
:=
setup
()
defer
teardown
(
server
)
mux
.
HandleFunc
(
"/api/v4/projects/1/variables/"
+
myKey
,
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
testMethod
(
t
,
r
,
"DELETE"
)
})
_
,
err
:=
client
.
BuildVariables
.
RemoveBuildVariable
(
1
,
myKey
)
if
err
!=
nil
{
t
.
Errorf
(
"RemoveBuildVariable returned error: %v"
,
err
)
}
}
gitlab.go
View file @
7537b744
...
...
@@ -304,7 +304,6 @@ type Client struct {
Boards
*
IssueBoardsService
Branches
*
BranchesService
BroadcastMessage
*
BroadcastMessagesService
BuildVariables
*
BuildVariablesService
CIYMLTemplate
*
CIYMLTemplatesService
Commits
*
CommitsService
ContainerRegistry
*
ContainerRegistryService
...
...
@@ -454,7 +453,6 @@ func newClient(httpClient *http.Client) *Client {
c
.
Boards
=
&
IssueBoardsService
{
client
:
c
}
c
.
Branches
=
&
BranchesService
{
client
:
c
}
c
.
BroadcastMessage
=
&
BroadcastMessagesService
{
client
:
c
}
c
.
BuildVariables
=
&
BuildVariablesService
{
client
:
c
}
c
.
CIYMLTemplate
=
&
CIYMLTemplatesService
{
client
:
c
}
c
.
Commits
=
&
CommitsService
{
client
:
c
}
c
.
ContainerRegistry
=
&
ContainerRegistryService
{
client
:
c
}
...
...
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