diff --git a/plugins/sourcegraph/access_token.go b/plugins/sourcegraph/access_token.go index aae6ada00..a837806e2 100644 --- a/plugins/sourcegraph/access_token.go +++ b/plugins/sourcegraph/access_token.go @@ -12,15 +12,15 @@ import ( func AccessToken() schema.CredentialType { return schema.CredentialType{ Name: credname.AccessToken, - DocsURL: sdk.URL("https://docs.sourcegraph.com/cli"), - ManagementURL: sdk.URL("https://sourcegraph.com/user/settings/tokens"), + DocsURL: sdk.URL("https://sourcegraph.com/docs/cli"), + ManagementURL: sdk.URL("https://sourcegraph.com/settings/tokens"), Fields: []schema.CredentialField{ { Name: fieldname.Endpoint, - MarkdownDescription: "Base URL for your Sourcegraph instance.", - Secret: false, - Optional: true, + AlternativeNames: []string{"Website", "URL"}, + MarkdownDescription: "Base URL for your Sourcegraph instance. Should start with https://", Composition: &schema.ValueComposition{ + Prefix: "https://", Charset: schema.Charset{ Lowercase: true, Digits: true, @@ -30,13 +30,16 @@ func AccessToken() schema.CredentialType { }, { Name: fieldname.Token, - MarkdownDescription: "Token used to authenticate to Sourcegraph.", + AlternativeNames: []string{"AccessToken"}, + MarkdownDescription: "Access token used to authenticate to Sourcegraph. Should start with sgp_", Secret: true, Composition: &schema.ValueComposition{ - Length: 40, + Prefix: "sgp_", Charset: schema.Charset{ + Uppercase: true, Lowercase: true, Digits: true, + Specific: []rune{'_'}, }, }, }, diff --git a/plugins/sourcegraph/access_token_test.go b/plugins/sourcegraph/access_token_test.go index aa95a2dcc..1cacffcb6 100644 --- a/plugins/sourcegraph/access_token_test.go +++ b/plugins/sourcegraph/access_token_test.go @@ -13,12 +13,12 @@ func TestAccessTokenProvisioner(t *testing.T) { "default": { ItemFields: map[sdk.FieldName]string{ fieldname.Endpoint: "https://sourcegraph.com", - fieldname.Token: "bqrv8bpqtplf7xv5lkk6oxfldtttmhzx4example", + fieldname.Token: "sgp_fake0123456789ab_fake0123456789abcdef0123456789abcdef0123", }, ExpectedOutput: sdk.ProvisionOutput{ Environment: map[string]string{ "SRC_ENDPOINT": "https://sourcegraph.com", - "SRC_ACCESS_TOKEN": "bqrv8bpqtplf7xv5lkk6oxfldtttmhzx4example", + "SRC_ACCESS_TOKEN": "sgp_fake0123456789ab_fake0123456789abcdef0123456789abcdef0123", }, }, }, @@ -30,13 +30,13 @@ func TestAccessTokenImporter(t *testing.T) { "environment": { Environment: map[string]string{ "SRC_ENDPOINT": "https://sourcegraph.com", - "SRC_ACCESS_TOKEN": "bqrv8bpqtplf7xv5lkk6oxfldtttmhzx4example", + "SRC_ACCESS_TOKEN": "sgp_fake0123456789ab_fake0123456789abcdef0123456789abcdef0123", }, ExpectedCandidates: []sdk.ImportCandidate{ { Fields: map[sdk.FieldName]string{ fieldname.Endpoint: "https://sourcegraph.com", - fieldname.Token: "bqrv8bpqtplf7xv5lkk6oxfldtttmhzx4example", + fieldname.Token: "sgp_fake0123456789ab_fake0123456789abcdef0123456789abcdef0123", }, }, }, diff --git a/plugins/sourcegraph/src.go b/plugins/sourcegraph/src.go index 47b4a791b..4b67b9aea 100644 --- a/plugins/sourcegraph/src.go +++ b/plugins/sourcegraph/src.go @@ -11,7 +11,7 @@ func SourcegraphCLI() schema.Executable { return schema.Executable{ Name: "Sourcegraph CLI", Runs: []string{"src"}, - DocsURL: sdk.URL("https://docs.sourcegraph.com/cli"), + DocsURL: sdk.URL("https://sourcegraph.com/docs/cli"), NeedsAuth: needsauth.IfAll( needsauth.NotForHelpOrVersion(), needsauth.NotWithoutArgs(),