Browse Source

made env variables more consistent with other providers

jabray5 4 years ago
parent
commit
349c193131
2 changed files with 7 additions and 6 deletions
  1. 5 4
      pkg/provider/gitlab/gitlab.go
  2. 2 2
      pkg/provider/gitlab/gitlab_test.go

+ 5 - 4
pkg/provider/gitlab/gitlab.go

@@ -21,25 +21,26 @@ import (
 )
 
 // Requires a token to be set in environment variable
-var GITLABTOKEN = os.Getenv("GITLABTOKEN")
+var GITLAB_TOKEN = os.Getenv("GITLABTOKEN")
+var GITLAB_PROJECT_ID = os.Getenv("GITLABPROJECTID")
 
 type GitlabCredentials struct {
 	Token string `json:"token"`
 }
 
-// Gitlab struct with values for *gitlab.Client and projectID
+// Gitlab struct with reference to a github client and a projectID
 type Gitlab struct {
 	client    *gitlab.Client
 	projectID interface{}
 }
 
-// Function newGitlabProvider returns a reference to a new Gitlab struct 'instance'
+// Function newGitlabProvider returns a reference to a new instance of a 'Gitlab' struct
 func NewGitlabProvider() *Gitlab {
 	return &Gitlab{}
 }
 
 // Method on Gitlab to set up client with credentials and populate projectID
-func (g *Gitlab) NewGitlabClient(cred GitlabCredentials, projectID int) {
+func (g *Gitlab) NewGitlabClient(cred GitlabCredentials, projectID string) {
 	var err error
 	// Create a new Gitlab client with credentials
 	g.client, err = gitlab.NewClient(cred.Token, nil)

+ 2 - 2
pkg/provider/gitlab/gitlab_test.go

@@ -19,9 +19,9 @@ import (
 )
 
 func TestCreateGitlabClient(t *testing.T) {
-	credentials := GitlabCredentials{Token: GITLABTOKEN}
+	credentials := GitlabCredentials{Token: GITLAB_TOKEN}
 	gitlab := NewGitlabProvider()
-	gitlab.NewGitlabClient(credentials, 28414983)
+	gitlab.NewGitlabClient(credentials, GITLAB_PROJECT_ID)
 
 	user, _, _ := gitlab.client.Users.CurrentUser()
 	fmt.Printf("Created client for username: %v", user)