Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
provider-gitlab
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
go-semantic-release
provider-gitlab
Commits
7276f320
Commit
7276f320
authored
4 years ago
by
Christoph Witzko
Browse files
Options
Downloads
Patches
Plain Diff
feat: also use environment for configuration
parent
3728e6e4
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/provider/gitlab.go
+21
-1
21 additions, 1 deletion
pkg/provider/gitlab.go
pkg/provider/gitlab_test.go
+1
-1
1 addition, 1 deletion
pkg/provider/gitlab_test.go
with
22 additions
and
2 deletions
pkg/provider/gitlab.go
+
21
−
1
View file @
7276f320
package
provider
package
provider
import
(
import
(
"errors"
"fmt"
"fmt"
"os"
"regexp"
"regexp"
"github.com/Masterminds/semver/v3"
"github.com/Masterminds/semver/v3"
...
@@ -18,11 +20,29 @@ type GitLabRepository struct {
...
@@ -18,11 +20,29 @@ type GitLabRepository struct {
func
(
repo
*
GitLabRepository
)
Init
(
config
map
[
string
]
string
)
error
{
func
(
repo
*
GitLabRepository
)
Init
(
config
map
[
string
]
string
)
error
{
gitlabBaseUrl
:=
config
[
"gitlabBaseUrl"
]
gitlabBaseUrl
:=
config
[
"gitlabBaseUrl"
]
if
gitlabBaseUrl
==
""
{
gitlabBaseUrl
=
os
.
Getenv
(
"CI_SERVER_URL"
)
}
token
:=
config
[
"token"
]
token
:=
config
[
"token"
]
if
token
==
""
{
token
=
os
.
Getenv
(
"GITLAB_TOKEN"
)
}
if
token
==
""
{
return
errors
.
New
(
"gitlab token missing"
)
}
branch
:=
config
[
"gitlabBranch"
]
branch
:=
config
[
"gitlabBranch"
]
if
branch
==
""
{
branch
=
os
.
Getenv
(
"CI_COMMIT_BRANCH"
)
}
projectID
:=
config
[
"gitlabProjectID"
]
projectID
:=
config
[
"gitlabProjectID"
]
if
projectID
==
""
{
if
projectID
==
""
{
return
fmt
.
Errorf
(
"project id is required"
)
projectID
=
os
.
Getenv
(
"CI_PROJECT_ID"
)
}
if
projectID
==
""
{
return
fmt
.
Errorf
(
"gitlabProjectID is required"
)
}
}
repo
.
projectID
=
projectID
repo
.
projectID
=
projectID
...
...
This diff is collapsed.
Click to expand it.
pkg/provider/gitlab_test.go
+
1
−
1
View file @
7276f320
...
@@ -20,7 +20,7 @@ func TestNewGitlabRepository(t *testing.T) {
...
@@ -20,7 +20,7 @@ func TestNewGitlabRepository(t *testing.T) {
var
repo
*
GitLabRepository
var
repo
*
GitLabRepository
repo
=
&
GitLabRepository
{}
repo
=
&
GitLabRepository
{}
err
:=
repo
.
Init
(
map
[
string
]
string
{})
err
:=
repo
.
Init
(
map
[
string
]
string
{})
require
.
EqualError
(
err
,
"
project id is required
"
)
require
.
EqualError
(
err
,
"
gitlab token missing
"
)
repo
=
&
GitLabRepository
{}
repo
=
&
GitLabRepository
{}
err
=
repo
.
Init
(
map
[
string
]
string
{
err
=
repo
.
Init
(
map
[
string
]
string
{
...
...
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