You've already forked go-semantic-release
fix(internal/releaser): add helper method to lookup for provider accesToken in environment variabels
This commit is contained in:
@@ -2,7 +2,10 @@ package util
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
@@ -17,3 +20,15 @@ func CreateBearerHTTPClient(ctx context.Context, token string) *http.Client {
|
||||
|
||||
return client
|
||||
}
|
||||
|
||||
// GetAccessToken lookup for the providers accesstoken
|
||||
func GetAccessToken(providerName string) (string, error) {
|
||||
var token string
|
||||
var exists bool
|
||||
envName := fmt.Sprintf("%s_ACCESS_TOKEN", strings.ToUpper(providerName))
|
||||
|
||||
if token, exists = os.LookupEnv(envName); !exists {
|
||||
return "", fmt.Errorf("Could not find %s in the enviroment variables. Please check if it is set", envName)
|
||||
}
|
||||
return token, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user