diff --git a/plugins/railway/api_token.go b/plugins/railway/api_token.go index 3b299f6b..60c41738 100644 --- a/plugins/railway/api_token.go +++ b/plugins/railway/api_token.go @@ -1,8 +1,6 @@ package railway import ( - "context" - "github.com/1Password/shell-plugins/sdk" "github.com/1Password/shell-plugins/sdk/importer" "github.com/1Password/shell-plugins/sdk/provision" @@ -14,8 +12,8 @@ import ( func APIToken() schema.CredentialType { return schema.CredentialType{ Name: credname.APIToken, - DocsURL: sdk.URL("https://railway.com/docs/api_token"), // TODO: Replace with actual URL - ManagementURL: sdk.URL("https://console.railway.com/user/security/tokens"), // TODO: Replace with actual URL + DocsURL: sdk.URL("https://docs.railway.app/guides/cli#authenticating-with-the-cli"), + ManagementURL: sdk.URL("https://railway.app/account/tokens"), Fields: []schema.CredentialField{ { Name: fieldname.Token, @@ -23,7 +21,6 @@ func APIToken() schema.CredentialType { Secret: true, Composition: &schema.ValueComposition{ Length: 36, - Prefix: "aa7b1a4b-7bb3-", // TODO: Check if this is correct Charset: schema.Charset{ Lowercase: true, Digits: true, @@ -34,37 +31,9 @@ func APIToken() schema.CredentialType { DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping), Importer: importer.TryAll( importer.TryEnvVarPair(defaultEnvVarMapping), - TryRailwayConfigFile(), )} } var defaultEnvVarMapping = map[string]sdk.FieldName{ - "RAILWAY_TOKEN": fieldname.Token, // TODO: Check if this is correct -} - -// TODO: Check if the platform stores the API Token in a local config file, and if so, -// implement the function below to add support for importing it. -func TryRailwayConfigFile() sdk.Importer { - return importer.TryFile("~/path/to/config/file.yml", func(ctx context.Context, contents importer.FileContents, in sdk.ImportInput, out *sdk.ImportAttempt) { - // var config Config - // if err := contents.ToYAML(&config); err != nil { - // out.AddError(err) - // return - // } - - // if config.Token == "" { - // return - // } - - // out.AddCandidate(sdk.ImportCandidate{ - // Fields: map[sdk.FieldName]string{ - // fieldname.Token: config.Token, - // }, - // }) - }) + "RAILWAY_API_TOKEN": fieldname.Token, } - -// TODO: Implement the config file schema -// type Config struct { -// Token string -// } diff --git a/plugins/railway/api_token_test.go b/plugins/railway/api_token_test.go index cf9982f8..00a677a6 100644 --- a/plugins/railway/api_token_test.go +++ b/plugins/railway/api_token_test.go @@ -2,21 +2,21 @@ package railway import ( "testing" - + "github.com/1Password/shell-plugins/sdk" "github.com/1Password/shell-plugins/sdk/plugintest" "github.com/1Password/shell-plugins/sdk/schema/fieldname" ) - + func TestAPITokenProvisioner(t *testing.T) { plugintest.TestProvisioner(t, APIToken().DefaultProvisioner, map[string]plugintest.ProvisionCase{ "default": { - ItemFields: map[sdk.FieldName]string{ // TODO: Check if this is correct + ItemFields: map[sdk.FieldName]string{ fieldname.Token: "abcdefghijklm-1234567890-example", }, ExpectedOutput: sdk.ProvisionOutput{ Environment: map[string]string{ - "RAILWAY_TOKEN": "abcdefghijklm-1234567890-example", + "RAILWAY_API_TOKEN": "abcdefghijklm-1234567890-example", }, }, }, @@ -26,8 +26,8 @@ func TestAPITokenProvisioner(t *testing.T) { func TestAPITokenImporter(t *testing.T) { plugintest.TestImporter(t, APIToken().Importer, map[string]plugintest.ImportCase{ "environment": { - Environment: map[string]string{ // TODO: Check if this is correct - "RAILWAY_TOKEN": "abcdefghijklm-1234567890-example", + Environment: map[string]string{ + "RAILWAY_API_TOKEN": "abcdefghijklm-1234567890-example", }, ExpectedCandidates: []sdk.ImportCandidate{ { @@ -37,19 +37,5 @@ func TestAPITokenImporter(t *testing.T) { }, }, }, - // TODO: If you implemented a config file importer, add a test file example in railway/test-fixtures - // and fill the necessary details in the test template below. - "config file": { - Files: map[string]string{ - // "~/path/to/config.yml": plugintest.LoadFixture(t, "config.yml"), - }, - ExpectedCandidates: []sdk.ImportCandidate{ - // { - // Fields: map[sdk.FieldName]string{ - // fieldname.Token: "abcdefghijklm-1234567890-example", - // }, - // }, - }, - }, }) } diff --git a/plugins/railway/plugin.go b/plugins/railway/plugin.go index 9478f2d8..95564fb9 100644 --- a/plugins/railway/plugin.go +++ b/plugins/railway/plugin.go @@ -10,7 +10,7 @@ func New() schema.Plugin { Name: "railway", Platform: schema.PlatformInfo{ Name: "Railway", - Homepage: sdk.URL("https://railway.com"), // TODO: Check if this is correct + Homepage: sdk.URL("https://railway.app"), }, Credentials: []schema.CredentialType{ APIToken(), diff --git a/plugins/railway/railway.go b/plugins/railway/railway.go index 81fcc9fb..08479116 100644 --- a/plugins/railway/railway.go +++ b/plugins/railway/railway.go @@ -9,9 +9,9 @@ import ( func RailwayCLI() schema.Executable { return schema.Executable{ - Name: "Railway CLI", // TODO: Check if this is correct - Runs: []string{"railway"}, - DocsURL: sdk.URL("https://railway.com/docs/cli"), // TODO: Replace with actual URL + Name: "Railway CLI", + Runs: []string{"railway"}, + DocsURL: sdk.URL("https://docs.railway.app/guides/cli"), NeedsAuth: needsauth.IfAll( needsauth.NotForHelpOrVersion(), needsauth.NotWithoutArgs(),