Loading internal/api/auth_sources.go +1 −14 Original line number Diff line number Diff line Loading @@ -6,10 +6,7 @@ import ( gitlab "gitlab.com/gitlab-org/api/client-go" ) var ( _ gitlab.AuthSource = (*oauth2AccessTokenOnlyAuthSource)(nil) _ gitlab.AuthSource = (*UnauthenticatedAuthSource)(nil) ) var _ gitlab.AuthSource = (*oauth2AccessTokenOnlyAuthSource)(nil) type oauth2AccessTokenOnlyAuthSource struct { token string Loading @@ -22,13 +19,3 @@ func (as oauth2AccessTokenOnlyAuthSource) Init(context.Context, *gitlab.Client) func (as oauth2AccessTokenOnlyAuthSource) Header(_ context.Context) (string, string, error) { return "Authorization", "Bearer " + as.token, nil } type UnauthenticatedAuthSource struct{} func (as UnauthenticatedAuthSource) Init(context.Context, *gitlab.Client) error { return nil } func (as UnauthenticatedAuthSource) Header(_ context.Context) (string, string, error) { return gitlab.AccessTokenHeaderName, "", nil } internal/api/client.go +1 −1 Original line number Diff line number Diff line Loading @@ -344,7 +344,7 @@ func NewClientFromConfig(repoHost string, cfg config.Config, isGraphQL bool, use default: // NOTE: use an unauthenticated client. newAuthSource = func(*http.Client) (gitlab.AuthSource, error) { return UnauthenticatedAuthSource{}, nil return gitlab.Unauthenticated{}, nil } } Loading internal/commands/auth/credentialhelper/credentialhelper.go +1 −1 Original line number Diff line number Diff line Loading @@ -154,7 +154,7 @@ func (o *options) run() responseType { Token: as.Token, }, } case api.UnauthenticatedAuthSource: case gitlab.Unauthenticated: return errorResponse{Message: "glab is not authenticated. Use glab auth login to authenticate"} default: return errorResponse{Message: "unable to determine token"} Loading internal/commands/auth/credentialhelper/credentialhelper_test.go +1 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ import ( gitlab "gitlab.com/gitlab-org/api/client-go" "gitlab.com/gitlab-org/cli/internal/api" "gitlab.com/gitlab-org/cli/internal/config" "gitlab.com/gitlab-org/cli/internal/testing/cmdtest" ) Loading Loading @@ -181,7 +180,7 @@ func TestCredentialHelper_ApiClientUnauthenticated(t *testing.T) { NewCmd, false, cmdtest.WithBaseRepo("OWNER", "REPO", "gitlab.example.com"), cmdtest.WithApiClient(cmdtest.NewTestAuthSourceApiClient(t, nil, api.UnauthenticatedAuthSource{}, "gitlab.example.com")), cmdtest.WithApiClient(cmdtest.NewTestAuthSourceApiClient(t, nil, gitlab.Unauthenticated{}, "gitlab.example.com")), ) out, err := exec("") Loading Loading
internal/api/auth_sources.go +1 −14 Original line number Diff line number Diff line Loading @@ -6,10 +6,7 @@ import ( gitlab "gitlab.com/gitlab-org/api/client-go" ) var ( _ gitlab.AuthSource = (*oauth2AccessTokenOnlyAuthSource)(nil) _ gitlab.AuthSource = (*UnauthenticatedAuthSource)(nil) ) var _ gitlab.AuthSource = (*oauth2AccessTokenOnlyAuthSource)(nil) type oauth2AccessTokenOnlyAuthSource struct { token string Loading @@ -22,13 +19,3 @@ func (as oauth2AccessTokenOnlyAuthSource) Init(context.Context, *gitlab.Client) func (as oauth2AccessTokenOnlyAuthSource) Header(_ context.Context) (string, string, error) { return "Authorization", "Bearer " + as.token, nil } type UnauthenticatedAuthSource struct{} func (as UnauthenticatedAuthSource) Init(context.Context, *gitlab.Client) error { return nil } func (as UnauthenticatedAuthSource) Header(_ context.Context) (string, string, error) { return gitlab.AccessTokenHeaderName, "", nil }
internal/api/client.go +1 −1 Original line number Diff line number Diff line Loading @@ -344,7 +344,7 @@ func NewClientFromConfig(repoHost string, cfg config.Config, isGraphQL bool, use default: // NOTE: use an unauthenticated client. newAuthSource = func(*http.Client) (gitlab.AuthSource, error) { return UnauthenticatedAuthSource{}, nil return gitlab.Unauthenticated{}, nil } } Loading
internal/commands/auth/credentialhelper/credentialhelper.go +1 −1 Original line number Diff line number Diff line Loading @@ -154,7 +154,7 @@ func (o *options) run() responseType { Token: as.Token, }, } case api.UnauthenticatedAuthSource: case gitlab.Unauthenticated: return errorResponse{Message: "glab is not authenticated. Use glab auth login to authenticate"} default: return errorResponse{Message: "unable to determine token"} Loading
internal/commands/auth/credentialhelper/credentialhelper_test.go +1 −2 Original line number Diff line number Diff line Loading @@ -18,7 +18,6 @@ import ( gitlab "gitlab.com/gitlab-org/api/client-go" "gitlab.com/gitlab-org/cli/internal/api" "gitlab.com/gitlab-org/cli/internal/config" "gitlab.com/gitlab-org/cli/internal/testing/cmdtest" ) Loading Loading @@ -181,7 +180,7 @@ func TestCredentialHelper_ApiClientUnauthenticated(t *testing.T) { NewCmd, false, cmdtest.WithBaseRepo("OWNER", "REPO", "gitlab.example.com"), cmdtest.WithApiClient(cmdtest.NewTestAuthSourceApiClient(t, nil, api.UnauthenticatedAuthSource{}, "gitlab.example.com")), cmdtest.WithApiClient(cmdtest.NewTestAuthSourceApiClient(t, nil, gitlab.Unauthenticated{}, "gitlab.example.com")), ) out, err := exec("") Loading