Skip to content

Commit

Permalink
cmd/gitops-pusher: fix logic for checking credentials
Browse files Browse the repository at this point in the history
gitops-pusher supports authenticating with an API key or OAuth
credentials (added in tailscale#7393). You shouldn't ever use both of those
together, so we error if both are set.

In tailscale/gitops-acl-action#24, OAuth support is being added to the
GitHub action. In that environment, both the TS_API_KEY and OAuth
variables will be set, even if they are empty values.  This causes an
error in gitops-pusher which expects only one to be set.

Update gitops-pusher to check that only one set of environment variables
are non-empty, rather than just checking if they are set.

Updates tailscale#7393

Signed-off-by: Will Norris <will@tailscale.com>
  • Loading branch information
willnorris committed Jan 29, 2024
1 parent cce189b commit 13f8a66
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/gitops-pusher/gitops-pusher.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func main() {
if !ok && (!oiok || !osok) {
log.Fatal("set envvar TS_API_KEY to your Tailscale API key or TS_OAUTH_ID and TS_OAUTH_SECRET to your Tailscale OAuth ID and Secret")
}
if ok && (oiok || osok) {
if apiKey != "" && (oauthId != "" || oauthSecret != "") {
log.Fatal("set either the envvar TS_API_KEY or TS_OAUTH_ID and TS_OAUTH_SECRET")
}
var client *http.Client
Expand Down

0 comments on commit 13f8a66

Please sign in to comment.