Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update some repo deps, cleanup a bit of logic, make notes about auth …
…impl Signed-off-by: Tony Worm <tony@hofstadter.io>
- Loading branch information
Showing
9 changed files
with
60 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
package gitlab | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/xanzy/go-gitlab" | ||
) | ||
|
||
const TokenEnv = "GITLAB_TOKEN" | ||
|
||
func NewClient() (client *gitlab.Client, err error) { | ||
return gitlab.NewClient(os.Getenv(TokenEnv)) | ||
func NewClient(private bool) (client *gitlab.Client, err error) { | ||
// TODO, there are multiple NewClient<> methods | ||
// how to determine which to use and the inputs to them | ||
// https://pkg.go.dev/github.com/xanzy/go-gitlab#NewOAuthClient | ||
// Noting also that we prefer auth over non-auth for API rate limits | ||
|
||
token := os.Getenv(TokenEnv) | ||
if private && token == "" { | ||
return nil, fmt.Errorf("Private module requested and no auth token available for %s", TokenEnv) | ||
} | ||
return gitlab.NewClient(token) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters