github.com/nathanielks/terraform@v0.6.1-0.20170509030759-13e1a62319dc/builtin/providers/gitlab/config.go (about) 1 package gitlab 2 3 import ( 4 "github.com/xanzy/go-gitlab" 5 ) 6 7 // Config is per-provider, specifies where to connect to gitlab 8 type Config struct { 9 Token string 10 BaseURL string 11 } 12 13 // Client returns a *gitlab.Client to interact with the configured gitlab instance 14 func (c *Config) Client() (interface{}, error) { 15 client := gitlab.NewClient(nil, c.Token) 16 if c.BaseURL != "" { 17 err := client.SetBaseURL(c.BaseURL) 18 if err != nil { 19 // The BaseURL supplied wasn't valid, bail. 20 return nil, err 21 } 22 } 23 24 // Test the credentials by checking we can get information about the authenticated user. 25 _, _, err := client.Users.CurrentUser() 26 if err != nil { 27 return nil, err 28 } 29 30 return client, nil 31 }