From cabd3209f11e56ebc475ece4a46e8440909535d0 Mon Sep 17 00:00:00 2001 From: Smyja Date: Thu, 22 Jun 2023 16:03:17 +0100 Subject: [PATCH 01/27] render initial setup Signed-off-by: Smyja --- plugins/render/api_key.go | 70 ++++++++++++++++++++++++++++++++++ plugins/render/api_key_test.go | 55 ++++++++++++++++++++++++++ plugins/render/plugin.go | 22 +++++++++++ plugins/render/render.go | 25 ++++++++++++ 4 files changed, 172 insertions(+) create mode 100644 plugins/render/api_key.go create mode 100644 plugins/render/api_key_test.go create mode 100644 plugins/render/plugin.go create mode 100644 plugins/render/render.go diff --git a/plugins/render/api_key.go b/plugins/render/api_key.go new file mode 100644 index 000000000..e428a5258 --- /dev/null +++ b/plugins/render/api_key.go @@ -0,0 +1,70 @@ +package render + +import ( + "context" + + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/importer" + "github.com/1Password/shell-plugins/sdk/provision" + "github.com/1Password/shell-plugins/sdk/schema" + "github.com/1Password/shell-plugins/sdk/schema/credname" + "github.com/1Password/shell-plugins/sdk/schema/fieldname" +) + +func APIKey() schema.CredentialType { + return schema.CredentialType{ + Name: credname.APIKey, + DocsURL: sdk.URL("https://render.com/docs/api_key"), // TODO: Replace with actual URL + ManagementURL: sdk.URL("https://console.render.com/user/security/tokens"), // TODO: Replace with actual URL + Fields: []schema.CredentialField{ + { + Name: fieldname.APIKey, + MarkdownDescription: "API Key used to authenticate to Render.", + Secret: true, + Composition: &schema.ValueComposition{ + Length: 10, + Charset: schema.Charset{ + Uppercase: true, + Lowercase: true, + Digits: true, + }, + }, + }, + }, + DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping), + Importer: importer.TryAll( + importer.TryEnvVarPair(defaultEnvVarMapping), + TryRenderConfigFile(), + )} +} + +var defaultEnvVarMapping = map[string]sdk.FieldName{ + "RENDER_API_KEY": fieldname.APIKey, // TODO: Check if this is correct +} + +// TODO: Check if the platform stores the API Key in a local config file, and if so, +// implement the function below to add support for importing it. +func TryRenderConfigFile() 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.APIKey == "" { + // return + // } + + // out.AddCandidate(sdk.ImportCandidate{ + // Fields: map[sdk.FieldName]string{ + // fieldname.APIKey: config.APIKey, + // }, + // }) + }) +} + +// TODO: Implement the config file schema +// type Config struct { +// APIKey string +// } diff --git a/plugins/render/api_key_test.go b/plugins/render/api_key_test.go new file mode 100644 index 000000000..fd91906f0 --- /dev/null +++ b/plugins/render/api_key_test.go @@ -0,0 +1,55 @@ +package render + +import ( + "testing" + + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/plugintest" + "github.com/1Password/shell-plugins/sdk/schema/fieldname" +) + +func TestAPIKeyProvisioner(t *testing.T) { + plugintest.TestProvisioner(t, APIKey().DefaultProvisioner, map[string]plugintest.ProvisionCase{ + "default": { + ItemFields: map[sdk.FieldName]string{ // TODO: Check if this is correct + fieldname.APIKey: "URUEXAMPLE", + }, + ExpectedOutput: sdk.ProvisionOutput{ + Environment: map[string]string{ + "RENDER_API_KEY": "URUEXAMPLE", + }, + }, + }, + }) +} + +func TestAPIKeyImporter(t *testing.T) { + plugintest.TestImporter(t, APIKey().Importer, map[string]plugintest.ImportCase{ + "environment": { + Environment: map[string]string{ // TODO: Check if this is correct + "RENDER_API_KEY": "URUEXAMPLE", + }, + ExpectedCandidates: []sdk.ImportCandidate{ + { + Fields: map[sdk.FieldName]string{ + fieldname.APIKey: "URUEXAMPLE", + }, + }, + }, + }, + // TODO: If you implemented a config file importer, add a test file example in render/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: "URUEXAMPLE", + // }, + // }, + }, + }, + }) +} diff --git a/plugins/render/plugin.go b/plugins/render/plugin.go new file mode 100644 index 000000000..1d8cd17ff --- /dev/null +++ b/plugins/render/plugin.go @@ -0,0 +1,22 @@ +package render + +import ( + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/schema" +) + +func New() schema.Plugin { + return schema.Plugin{ + Name: "render", + Platform: schema.PlatformInfo{ + Name: "Render", + Homepage: sdk.URL("https://render.com"), // TODO: Check if this is correct + }, + Credentials: []schema.CredentialType{ + APIKey(), + }, + Executables: []schema.Executable{ + RenderCLI(), + }, + } +} diff --git a/plugins/render/render.go b/plugins/render/render.go new file mode 100644 index 000000000..5f81e7387 --- /dev/null +++ b/plugins/render/render.go @@ -0,0 +1,25 @@ +package render + +import ( + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/needsauth" + "github.com/1Password/shell-plugins/sdk/schema" + "github.com/1Password/shell-plugins/sdk/schema/credname" +) + +func RenderCLI() schema.Executable { + return schema.Executable{ + Name: "Render CLI", // TODO: Check if this is correct + Runs: []string{"render"}, + DocsURL: sdk.URL("https://render.com/docs/cli"), // TODO: Replace with actual URL + NeedsAuth: needsauth.IfAll( + needsauth.NotForHelpOrVersion(), + needsauth.NotWithoutArgs(), + ), + Uses: []schema.CredentialUsage{ + { + Name: credname.APIKey, + }, + }, + } +} From 3671af33d5fe648f88aac5c9efc9bb189e79e3ac Mon Sep 17 00:00:00 2001 From: Smyja Date: Thu, 22 Jun 2023 17:05:44 +0100 Subject: [PATCH 02/27] updated file struct Signed-off-by: Smyja --- plugins/render/api_key.go | 58 +++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/plugins/render/api_key.go b/plugins/render/api_key.go index e428a5258..710eef8b6 100644 --- a/plugins/render/api_key.go +++ b/plugins/render/api_key.go @@ -11,18 +11,29 @@ import ( "github.com/1Password/shell-plugins/sdk/schema/fieldname" ) +type Config struct { + Version int + SSHPreserveHosts bool `yaml:"sshPreserveHosts"` + Profiles map[string]Profile +} + +type Profile struct { + DefaultRegion string `yaml:"defaultRegion"` + APIKey string `yaml:"apiKey"` +} + func APIKey() schema.CredentialType { return schema.CredentialType{ Name: credname.APIKey, - DocsURL: sdk.URL("https://render.com/docs/api_key"), // TODO: Replace with actual URL - ManagementURL: sdk.URL("https://console.render.com/user/security/tokens"), // TODO: Replace with actual URL + DocsURL: sdk.URL("https://render.com/docs/api_key"), + ManagementURL: sdk.URL("https://console.render.com/user/security/tokens"), Fields: []schema.CredentialField{ { Name: fieldname.APIKey, MarkdownDescription: "API Key used to authenticate to Render.", Secret: true, Composition: &schema.ValueComposition{ - Length: 10, + Length: 30, Charset: schema.Charset{ Uppercase: true, Lowercase: true, @@ -35,36 +46,31 @@ func APIKey() schema.CredentialType { Importer: importer.TryAll( importer.TryEnvVarPair(defaultEnvVarMapping), TryRenderConfigFile(), - )} + ), + } } var defaultEnvVarMapping = map[string]sdk.FieldName{ - "RENDER_API_KEY": fieldname.APIKey, // TODO: Check if this is correct + "RENDER_API_KEY": fieldname.APIKey, } -// TODO: Check if the platform stores the API Key in a local config file, and if so, -// implement the function below to add support for importing it. func TryRenderConfigFile() 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 - // } + return importer.TryFile(".render/config.yaml", 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.APIKey == "" { - // return - // } + profile, ok := config.Profiles["default"] + if !ok || profile.APIKey == "" { + return + } - // out.AddCandidate(sdk.ImportCandidate{ - // Fields: map[sdk.FieldName]string{ - // fieldname.APIKey: config.APIKey, - // }, - // }) + out.AddCandidate(sdk.ImportCandidate{ + Fields: map[sdk.FieldName]string{ + fieldname.APIKey: profile.APIKey, + }, + }) }) } - -// TODO: Implement the config file schema -// type Config struct { -// APIKey string -// } From 2d57bbf1e86675c3d804f162897fadc3f78daefd Mon Sep 17 00:00:00 2001 From: Smyja Date: Sat, 24 Jun 2023 21:03:30 +0100 Subject: [PATCH 03/27] update Signed-off-by: Smyja --- plugins/render/api_key.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/plugins/render/api_key.go b/plugins/render/api_key.go index 710eef8b6..5b9d445a5 100644 --- a/plugins/render/api_key.go +++ b/plugins/render/api_key.go @@ -12,20 +12,17 @@ import ( ) type Config struct { - Version int - SSHPreserveHosts bool `yaml:"sshPreserveHosts"` Profiles map[string]Profile } type Profile struct { - DefaultRegion string `yaml:"defaultRegion"` APIKey string `yaml:"apiKey"` } func APIKey() schema.CredentialType { return schema.CredentialType{ Name: credname.APIKey, - DocsURL: sdk.URL("https://render.com/docs/api_key"), + DocsURL: sdk.URL("https://render.com/docs"), ManagementURL: sdk.URL("https://console.render.com/user/security/tokens"), Fields: []schema.CredentialField{ { @@ -51,7 +48,6 @@ func APIKey() schema.CredentialType { } var defaultEnvVarMapping = map[string]sdk.FieldName{ - "RENDER_API_KEY": fieldname.APIKey, } func TryRenderConfigFile() sdk.Importer { From 1ddd1f54653b9e3e7e2a9dd90ef7422ace183f8b Mon Sep 17 00:00:00 2001 From: Smyja Date: Sat, 24 Jun 2023 21:07:50 +0100 Subject: [PATCH 04/27] fixed management url Signed-off-by: Smyja --- plugins/render/api_key.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/render/api_key.go b/plugins/render/api_key.go index 5b9d445a5..c63f895e3 100644 --- a/plugins/render/api_key.go +++ b/plugins/render/api_key.go @@ -23,7 +23,7 @@ func APIKey() schema.CredentialType { return schema.CredentialType{ Name: credname.APIKey, DocsURL: sdk.URL("https://render.com/docs"), - ManagementURL: sdk.URL("https://console.render.com/user/security/tokens"), + ManagementURL: sdk.URL("https://dashboard.render.com/u/settings#api-keys"), Fields: []schema.CredentialField{ { Name: fieldname.APIKey, From fe27df5adadb6f16552cbaa2ca517d70b39f2603 Mon Sep 17 00:00:00 2001 From: Smyja Date: Sat, 24 Jun 2023 21:14:50 +0100 Subject: [PATCH 05/27] updated test file Signed-off-by: Smyja --- plugins/render/api_key_test.go | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/plugins/render/api_key_test.go b/plugins/render/api_key_test.go index fd91906f0..3e1f60534 100644 --- a/plugins/render/api_key_test.go +++ b/plugins/render/api_key_test.go @@ -12,12 +12,7 @@ func TestAPIKeyProvisioner(t *testing.T) { plugintest.TestProvisioner(t, APIKey().DefaultProvisioner, map[string]plugintest.ProvisionCase{ "default": { ItemFields: map[sdk.FieldName]string{ // TODO: Check if this is correct - fieldname.APIKey: "URUEXAMPLE", - }, - ExpectedOutput: sdk.ProvisionOutput{ - Environment: map[string]string{ - "RENDER_API_KEY": "URUEXAMPLE", - }, + fieldname.APIKey: "rnd_Z7xMKp4NX1FoQNRyBpZs9yxDbu3i", }, }, }) @@ -27,12 +22,12 @@ func TestAPIKeyImporter(t *testing.T) { plugintest.TestImporter(t, APIKey().Importer, map[string]plugintest.ImportCase{ "environment": { Environment: map[string]string{ // TODO: Check if this is correct - "RENDER_API_KEY": "URUEXAMPLE", + "RENDER_API_KEY": "rnd_Z7xMKp4NX1FoQNRyBpZs9yxDbu3i", }, ExpectedCandidates: []sdk.ImportCandidate{ { Fields: map[sdk.FieldName]string{ - fieldname.APIKey: "URUEXAMPLE", + fieldname.APIKey: "rnd_Z7xMKp4NX1FoQNRyBpZs9yxDbu3i", }, }, }, @@ -41,14 +36,14 @@ func TestAPIKeyImporter(t *testing.T) { // 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"), + ".render/config.yaml": plugintest.LoadFixture(t, "config.yml"), }, ExpectedCandidates: []sdk.ImportCandidate{ - // { - // Fields: map[sdk.FieldName]string{ - // fieldname.Token: "URUEXAMPLE", - // }, - // }, + { + Fields: map[sdk.FieldName]string{ + fieldname.APIKey: "rnd_Z7xMKp4NX1FoQNRyBpZs9yxDbu3i", + }, + }, }, }, }) From bf892a912baf4305d5fb9a52dad521c7512e535e Mon Sep 17 00:00:00 2001 From: Smyja Date: Sun, 25 Jun 2023 20:16:30 +0100 Subject: [PATCH 06/27] Deta.space initital setup Signed-off-by: Smyja --- plugins/deta/api_key.go | 71 ++++++++++++++++++++++++++++++++++++ plugins/deta/api_key_test.go | 55 ++++++++++++++++++++++++++++ plugins/deta/plugin.go | 22 +++++++++++ plugins/deta/space.go | 25 +++++++++++++ 4 files changed, 173 insertions(+) create mode 100644 plugins/deta/api_key.go create mode 100644 plugins/deta/api_key_test.go create mode 100644 plugins/deta/plugin.go create mode 100644 plugins/deta/space.go diff --git a/plugins/deta/api_key.go b/plugins/deta/api_key.go new file mode 100644 index 000000000..1dc3fd324 --- /dev/null +++ b/plugins/deta/api_key.go @@ -0,0 +1,71 @@ +package deta + +import ( + "context" + + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/importer" + "github.com/1Password/shell-plugins/sdk/provision" + "github.com/1Password/shell-plugins/sdk/schema" + "github.com/1Password/shell-plugins/sdk/schema/credname" + "github.com/1Password/shell-plugins/sdk/schema/fieldname" +) + +func APIKey() schema.CredentialType { + return schema.CredentialType{ + Name: credname.APIKey, + DocsURL: sdk.URL("https://deta.com/docs/api_key"), // TODO: Replace with actual URL + ManagementURL: sdk.URL("https://console.deta.com/user/security/tokens"), // TODO: Replace with actual URL + Fields: []schema.CredentialField{ + { + Name: fieldname.APIKey, + MarkdownDescription: "API Key used to authenticate to Deta.", + Secret: true, + Composition: &schema.ValueComposition{ + Length: 25, + Prefix: "bE53FsM6_", // TODO: Check if this is correct + Charset: schema.Charset{ + Uppercase: true, + Lowercase: true, + Digits: true, + }, + }, + }, + }, + DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping), + Importer: importer.TryAll( + importer.TryEnvVarPair(defaultEnvVarMapping), + TryDetaConfigFile(), + )} +} + +var defaultEnvVarMapping = map[string]sdk.FieldName{ + "DETA_API_KEY": fieldname.APIKey, // TODO: Check if this is correct +} + +// TODO: Check if the platform stores the API Key in a local config file, and if so, +// implement the function below to add support for importing it. +func TryDetaConfigFile() 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.APIKey == "" { + // return + // } + + // out.AddCandidate(sdk.ImportCandidate{ + // Fields: map[sdk.FieldName]string{ + // fieldname.APIKey: config.APIKey, + // }, + // }) + }) +} + +// TODO: Implement the config file schema +// type Config struct { +// APIKey string +// } diff --git a/plugins/deta/api_key_test.go b/plugins/deta/api_key_test.go new file mode 100644 index 000000000..9102d45a6 --- /dev/null +++ b/plugins/deta/api_key_test.go @@ -0,0 +1,55 @@ +package deta + +import ( + "testing" + + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/plugintest" + "github.com/1Password/shell-plugins/sdk/schema/fieldname" +) + +func TestAPIKeyProvisioner(t *testing.T) { + plugintest.TestProvisioner(t, APIKey().DefaultProvisioner, map[string]plugintest.ProvisionCase{ + "default": { + ItemFields: map[sdk.FieldName]string{ // TODO: Check if this is correct + fieldname.APIKey: "bE53FsM6_MPPjP3sg6EXAMPLE", + }, + ExpectedOutput: sdk.ProvisionOutput{ + Environment: map[string]string{ + "DETA_API_KEY": "bE53FsM6_MPPjP3sg6EXAMPLE", + }, + }, + }, + }) +} + +func TestAPIKeyImporter(t *testing.T) { + plugintest.TestImporter(t, APIKey().Importer, map[string]plugintest.ImportCase{ + "environment": { + Environment: map[string]string{ // TODO: Check if this is correct + "DETA_API_KEY": "bE53FsM6_MPPjP3sg6EXAMPLE", + }, + ExpectedCandidates: []sdk.ImportCandidate{ + { + Fields: map[sdk.FieldName]string{ + fieldname.APIKey: "bE53FsM6_MPPjP3sg6EXAMPLE", + }, + }, + }, + }, + // TODO: If you implemented a config file importer, add a test file example in deta/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: "bE53FsM6_MPPjP3sg6EXAMPLE", + // }, + // }, + }, + }, + }) +} diff --git a/plugins/deta/plugin.go b/plugins/deta/plugin.go new file mode 100644 index 000000000..1b8f50ef6 --- /dev/null +++ b/plugins/deta/plugin.go @@ -0,0 +1,22 @@ +package deta + +import ( + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/schema" +) + +func New() schema.Plugin { + return schema.Plugin{ + Name: "deta", + Platform: schema.PlatformInfo{ + Name: "Deta", + Homepage: sdk.URL("https://deta.com"), // TODO: Check if this is correct + }, + Credentials: []schema.CredentialType{ + APIKey(), + }, + Executables: []schema.Executable{ + DetaCLI(), + }, + } +} diff --git a/plugins/deta/space.go b/plugins/deta/space.go new file mode 100644 index 000000000..ae437ab93 --- /dev/null +++ b/plugins/deta/space.go @@ -0,0 +1,25 @@ +package deta + +import ( + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/needsauth" + "github.com/1Password/shell-plugins/sdk/schema" + "github.com/1Password/shell-plugins/sdk/schema/credname" +) + +func DetaCLI() schema.Executable { + return schema.Executable{ + Name: "Deta CLI", // TODO: Check if this is correct + Runs: []string{"space"}, + DocsURL: sdk.URL("https://deta.com/docs/cli"), // TODO: Replace with actual URL + NeedsAuth: needsauth.IfAll( + needsauth.NotForHelpOrVersion(), + needsauth.NotWithoutArgs(), + ), + Uses: []schema.CredentialUsage{ + { + Name: credname.APIKey, + }, + }, + } +} From 5c8c30bbe3eb45db3f515994fcb0e6bec492ac65 Mon Sep 17 00:00:00 2001 From: Smyja Date: Mon, 26 Jun 2023 16:55:27 +0100 Subject: [PATCH 07/27] update Signed-off-by: Smyja --- plugins/deta/api_key.go | 71 ------------------------------------ plugins/deta/api_key_test.go | 55 ---------------------------- plugins/deta/plugin.go | 22 ----------- plugins/deta/space.go | 25 ------------- 4 files changed, 173 deletions(-) delete mode 100644 plugins/deta/api_key.go delete mode 100644 plugins/deta/api_key_test.go delete mode 100644 plugins/deta/plugin.go delete mode 100644 plugins/deta/space.go diff --git a/plugins/deta/api_key.go b/plugins/deta/api_key.go deleted file mode 100644 index 1dc3fd324..000000000 --- a/plugins/deta/api_key.go +++ /dev/null @@ -1,71 +0,0 @@ -package deta - -import ( - "context" - - "github.com/1Password/shell-plugins/sdk" - "github.com/1Password/shell-plugins/sdk/importer" - "github.com/1Password/shell-plugins/sdk/provision" - "github.com/1Password/shell-plugins/sdk/schema" - "github.com/1Password/shell-plugins/sdk/schema/credname" - "github.com/1Password/shell-plugins/sdk/schema/fieldname" -) - -func APIKey() schema.CredentialType { - return schema.CredentialType{ - Name: credname.APIKey, - DocsURL: sdk.URL("https://deta.com/docs/api_key"), // TODO: Replace with actual URL - ManagementURL: sdk.URL("https://console.deta.com/user/security/tokens"), // TODO: Replace with actual URL - Fields: []schema.CredentialField{ - { - Name: fieldname.APIKey, - MarkdownDescription: "API Key used to authenticate to Deta.", - Secret: true, - Composition: &schema.ValueComposition{ - Length: 25, - Prefix: "bE53FsM6_", // TODO: Check if this is correct - Charset: schema.Charset{ - Uppercase: true, - Lowercase: true, - Digits: true, - }, - }, - }, - }, - DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping), - Importer: importer.TryAll( - importer.TryEnvVarPair(defaultEnvVarMapping), - TryDetaConfigFile(), - )} -} - -var defaultEnvVarMapping = map[string]sdk.FieldName{ - "DETA_API_KEY": fieldname.APIKey, // TODO: Check if this is correct -} - -// TODO: Check if the platform stores the API Key in a local config file, and if so, -// implement the function below to add support for importing it. -func TryDetaConfigFile() 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.APIKey == "" { - // return - // } - - // out.AddCandidate(sdk.ImportCandidate{ - // Fields: map[sdk.FieldName]string{ - // fieldname.APIKey: config.APIKey, - // }, - // }) - }) -} - -// TODO: Implement the config file schema -// type Config struct { -// APIKey string -// } diff --git a/plugins/deta/api_key_test.go b/plugins/deta/api_key_test.go deleted file mode 100644 index 9102d45a6..000000000 --- a/plugins/deta/api_key_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package deta - -import ( - "testing" - - "github.com/1Password/shell-plugins/sdk" - "github.com/1Password/shell-plugins/sdk/plugintest" - "github.com/1Password/shell-plugins/sdk/schema/fieldname" -) - -func TestAPIKeyProvisioner(t *testing.T) { - plugintest.TestProvisioner(t, APIKey().DefaultProvisioner, map[string]plugintest.ProvisionCase{ - "default": { - ItemFields: map[sdk.FieldName]string{ // TODO: Check if this is correct - fieldname.APIKey: "bE53FsM6_MPPjP3sg6EXAMPLE", - }, - ExpectedOutput: sdk.ProvisionOutput{ - Environment: map[string]string{ - "DETA_API_KEY": "bE53FsM6_MPPjP3sg6EXAMPLE", - }, - }, - }, - }) -} - -func TestAPIKeyImporter(t *testing.T) { - plugintest.TestImporter(t, APIKey().Importer, map[string]plugintest.ImportCase{ - "environment": { - Environment: map[string]string{ // TODO: Check if this is correct - "DETA_API_KEY": "bE53FsM6_MPPjP3sg6EXAMPLE", - }, - ExpectedCandidates: []sdk.ImportCandidate{ - { - Fields: map[sdk.FieldName]string{ - fieldname.APIKey: "bE53FsM6_MPPjP3sg6EXAMPLE", - }, - }, - }, - }, - // TODO: If you implemented a config file importer, add a test file example in deta/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: "bE53FsM6_MPPjP3sg6EXAMPLE", - // }, - // }, - }, - }, - }) -} diff --git a/plugins/deta/plugin.go b/plugins/deta/plugin.go deleted file mode 100644 index 1b8f50ef6..000000000 --- a/plugins/deta/plugin.go +++ /dev/null @@ -1,22 +0,0 @@ -package deta - -import ( - "github.com/1Password/shell-plugins/sdk" - "github.com/1Password/shell-plugins/sdk/schema" -) - -func New() schema.Plugin { - return schema.Plugin{ - Name: "deta", - Platform: schema.PlatformInfo{ - Name: "Deta", - Homepage: sdk.URL("https://deta.com"), // TODO: Check if this is correct - }, - Credentials: []schema.CredentialType{ - APIKey(), - }, - Executables: []schema.Executable{ - DetaCLI(), - }, - } -} diff --git a/plugins/deta/space.go b/plugins/deta/space.go deleted file mode 100644 index ae437ab93..000000000 --- a/plugins/deta/space.go +++ /dev/null @@ -1,25 +0,0 @@ -package deta - -import ( - "github.com/1Password/shell-plugins/sdk" - "github.com/1Password/shell-plugins/sdk/needsauth" - "github.com/1Password/shell-plugins/sdk/schema" - "github.com/1Password/shell-plugins/sdk/schema/credname" -) - -func DetaCLI() schema.Executable { - return schema.Executable{ - Name: "Deta CLI", // TODO: Check if this is correct - Runs: []string{"space"}, - DocsURL: sdk.URL("https://deta.com/docs/cli"), // TODO: Replace with actual URL - NeedsAuth: needsauth.IfAll( - needsauth.NotForHelpOrVersion(), - needsauth.NotWithoutArgs(), - ), - Uses: []schema.CredentialUsage{ - { - Name: credname.APIKey, - }, - }, - } -} From 71ae6a250bb2e9d71d32ebb8b387ea6f75494d80 Mon Sep 17 00:00:00 2001 From: Smyja Date: Mon, 26 Jun 2023 17:26:31 +0100 Subject: [PATCH 08/27] update Signed-off-by: Smyja --- plugins/render/api_key.go | 16 +++++++++++++--- plugins/render/render.go | 8 ++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/plugins/render/api_key.go b/plugins/render/api_key.go index c63f895e3..d4269e3d5 100644 --- a/plugins/render/api_key.go +++ b/plugins/render/api_key.go @@ -9,6 +9,7 @@ import ( "github.com/1Password/shell-plugins/sdk/schema" "github.com/1Password/shell-plugins/sdk/schema/credname" "github.com/1Password/shell-plugins/sdk/schema/fieldname" + "gopkg.in/yaml.v2" ) type Config struct { @@ -39,15 +40,24 @@ func APIKey() schema.CredentialType { }, }, }, - DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping), + DefaultProvisioner: provision.TempFile(renderConfig, provision.AtFixedPath(ConfigPath())), Importer: importer.TryAll( - importer.TryEnvVarPair(defaultEnvVarMapping), TryRenderConfigFile(), ), } } -var defaultEnvVarMapping = map[string]sdk.FieldName{ +// var defaultEnvVarMapping = map[string]sdk.FieldName{ +// } +func renderConfig(in sdk.ProvisionInput) ([]byte, error) { + config := Config{ + + } + contents, err := yaml.Marshal(&config) + if err != nil { + return nil, err + } + return []byte(contents), nil } func TryRenderConfigFile() sdk.Importer { diff --git a/plugins/render/render.go b/plugins/render/render.go index 5f81e7387..a52daabf1 100644 --- a/plugins/render/render.go +++ b/plugins/render/render.go @@ -1,11 +1,19 @@ package render import ( + "os" "github.com/1Password/shell-plugins/sdk" "github.com/1Password/shell-plugins/sdk/needsauth" "github.com/1Password/shell-plugins/sdk/schema" "github.com/1Password/shell-plugins/sdk/schema/credname" ) +func ConfigPath() string { + configDir, err := os.UserConfigDir() + if err != nil { + return "~/.render/config.yaml" + } + return configDir + "/render/config.yaml" +} func RenderCLI() schema.Executable { return schema.Executable{ From f2b5c6ebd543dfd5b9dd71daa35995e2c0b97148 Mon Sep 17 00:00:00 2001 From: Smyja Date: Wed, 28 Jun 2023 08:59:11 +0100 Subject: [PATCH 09/27] removed comment Signed-off-by: Smyja --- plugins/render/api_key.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/render/api_key.go b/plugins/render/api_key.go index d4269e3d5..c01301f6b 100644 --- a/plugins/render/api_key.go +++ b/plugins/render/api_key.go @@ -47,8 +47,6 @@ func APIKey() schema.CredentialType { } } -// var defaultEnvVarMapping = map[string]sdk.FieldName{ -// } func renderConfig(in sdk.ProvisionInput) ([]byte, error) { config := Config{ From 20942ccc5fd6dc37bfba9c70b7e1ba597ee70f03 Mon Sep 17 00:00:00 2001 From: Smyja Date: Wed, 28 Jun 2023 09:04:21 +0100 Subject: [PATCH 10/27] removed todos Signed-off-by: Smyja --- plugins/render/render.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/render/render.go b/plugins/render/render.go index a52daabf1..e836a0d61 100644 --- a/plugins/render/render.go +++ b/plugins/render/render.go @@ -17,9 +17,9 @@ func ConfigPath() string { func RenderCLI() schema.Executable { return schema.Executable{ - Name: "Render CLI", // TODO: Check if this is correct + Name: "Render CLI", Runs: []string{"render"}, - DocsURL: sdk.URL("https://render.com/docs/cli"), // TODO: Replace with actual URL + DocsURL: sdk.URL("https://render.com/docs/cli"), NeedsAuth: needsauth.IfAll( needsauth.NotForHelpOrVersion(), needsauth.NotWithoutArgs(), From 1ef074eb087cd22457ec4fa991a90b92bbb75198 Mon Sep 17 00:00:00 2001 From: Smyja Date: Wed, 28 Jun 2023 09:05:08 +0100 Subject: [PATCH 11/27] removed apikey importer test Signed-off-by: Smyja --- plugins/render/api_key_test.go | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/plugins/render/api_key_test.go b/plugins/render/api_key_test.go index 3e1f60534..c815d5115 100644 --- a/plugins/render/api_key_test.go +++ b/plugins/render/api_key_test.go @@ -18,33 +18,4 @@ func TestAPIKeyProvisioner(t *testing.T) { }) } -func TestAPIKeyImporter(t *testing.T) { - plugintest.TestImporter(t, APIKey().Importer, map[string]plugintest.ImportCase{ - "environment": { - Environment: map[string]string{ // TODO: Check if this is correct - "RENDER_API_KEY": "rnd_Z7xMKp4NX1FoQNRyBpZs9yxDbu3i", - }, - ExpectedCandidates: []sdk.ImportCandidate{ - { - Fields: map[sdk.FieldName]string{ - fieldname.APIKey: "rnd_Z7xMKp4NX1FoQNRyBpZs9yxDbu3i", - }, - }, - }, - }, - // TODO: If you implemented a config file importer, add a test file example in render/test-fixtures - // and fill the necessary details in the test template below. - "config file": { - Files: map[string]string{ - ".render/config.yaml": plugintest.LoadFixture(t, "config.yml"), - }, - ExpectedCandidates: []sdk.ImportCandidate{ - { - Fields: map[sdk.FieldName]string{ - fieldname.APIKey: "rnd_Z7xMKp4NX1FoQNRyBpZs9yxDbu3i", - }, - }, - }, - }, - }) -} + From e087922176be71d852d2c7b5125c2540099751a2 Mon Sep 17 00:00:00 2001 From: Smyja Date: Wed, 28 Jun 2023 09:06:23 +0100 Subject: [PATCH 12/27] changed config file path Signed-off-by: Smyja --- plugins/render/api_key.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/render/api_key.go b/plugins/render/api_key.go index c01301f6b..3a14e79ba 100644 --- a/plugins/render/api_key.go +++ b/plugins/render/api_key.go @@ -59,7 +59,7 @@ func renderConfig(in sdk.ProvisionInput) ([]byte, error) { } func TryRenderConfigFile() sdk.Importer { - return importer.TryFile(".render/config.yaml", func(ctx context.Context, contents importer.FileContents, in sdk.ImportInput, out *sdk.ImportAttempt) { + return importer.TryFile("~/.render/config.yaml", 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) From 1acb973f033da7727f5ef19e2c4912f46d34cd3e Mon Sep 17 00:00:00 2001 From: Smyja Date: Wed, 28 Jun 2023 09:09:01 +0100 Subject: [PATCH 13/27] removed todo Signed-off-by: Smyja --- plugins/render/plugin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/render/plugin.go b/plugins/render/plugin.go index 1d8cd17ff..ff35b9c69 100644 --- a/plugins/render/plugin.go +++ b/plugins/render/plugin.go @@ -10,7 +10,7 @@ func New() schema.Plugin { Name: "render", Platform: schema.PlatformInfo{ Name: "Render", - Homepage: sdk.URL("https://render.com"), // TODO: Check if this is correct + Homepage: sdk.URL("https://render.com"), }, Credentials: []schema.CredentialType{ APIKey(), From 787c9a44eef950b2070f9dfb2c5e8341c72ec39b Mon Sep 17 00:00:00 2001 From: Smyja Date: Wed, 28 Jun 2023 09:19:15 +0100 Subject: [PATCH 14/27] fixed formatting Signed-off-by: Smyja --- plugins/render/api_key.go | 8 +++----- plugins/render/api_key_test.go | 6 ++---- plugins/render/render.go | 9 +++++---- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/plugins/render/api_key.go b/plugins/render/api_key.go index 3a14e79ba..793ab642a 100644 --- a/plugins/render/api_key.go +++ b/plugins/render/api_key.go @@ -13,11 +13,11 @@ import ( ) type Config struct { - Profiles map[string]Profile + Profiles map[string]Profile } type Profile struct { - APIKey string `yaml:"apiKey"` + APIKey string `yaml:"apiKey"` } func APIKey() schema.CredentialType { @@ -48,9 +48,7 @@ func APIKey() schema.CredentialType { } func renderConfig(in sdk.ProvisionInput) ([]byte, error) { - config := Config{ - - } + config := Config{} contents, err := yaml.Marshal(&config) if err != nil { return nil, err diff --git a/plugins/render/api_key_test.go b/plugins/render/api_key_test.go index c815d5115..6a8d761ae 100644 --- a/plugins/render/api_key_test.go +++ b/plugins/render/api_key_test.go @@ -2,12 +2,12 @@ package render import ( "testing" - + "github.com/1Password/shell-plugins/sdk" "github.com/1Password/shell-plugins/sdk/plugintest" "github.com/1Password/shell-plugins/sdk/schema/fieldname" ) - + func TestAPIKeyProvisioner(t *testing.T) { plugintest.TestProvisioner(t, APIKey().DefaultProvisioner, map[string]plugintest.ProvisionCase{ "default": { @@ -17,5 +17,3 @@ func TestAPIKeyProvisioner(t *testing.T) { }, }) } - - diff --git a/plugins/render/render.go b/plugins/render/render.go index e836a0d61..2935f68b0 100644 --- a/plugins/render/render.go +++ b/plugins/render/render.go @@ -1,12 +1,13 @@ package render import ( - "os" "github.com/1Password/shell-plugins/sdk" "github.com/1Password/shell-plugins/sdk/needsauth" "github.com/1Password/shell-plugins/sdk/schema" "github.com/1Password/shell-plugins/sdk/schema/credname" + "os" ) + func ConfigPath() string { configDir, err := os.UserConfigDir() if err != nil { @@ -17,9 +18,9 @@ func ConfigPath() string { func RenderCLI() schema.Executable { return schema.Executable{ - Name: "Render CLI", - Runs: []string{"render"}, - DocsURL: sdk.URL("https://render.com/docs/cli"), + Name: "Render CLI", + Runs: []string{"render"}, + DocsURL: sdk.URL("https://render.com/docs/cli"), NeedsAuth: needsauth.IfAll( needsauth.NotForHelpOrVersion(), needsauth.NotWithoutArgs(), From 3538e22587133457717af48864edc8ce6cb1e58c Mon Sep 17 00:00:00 2001 From: Smyja Date: Wed, 28 Jun 2023 11:07:04 +0100 Subject: [PATCH 15/27] removed default Signed-off-by: Smyja --- plugins/render/api_key.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/plugins/render/api_key.go b/plugins/render/api_key.go index 793ab642a..9a77d35e7 100644 --- a/plugins/render/api_key.go +++ b/plugins/render/api_key.go @@ -64,15 +64,18 @@ func TryRenderConfigFile() sdk.Importer { return } - profile, ok := config.Profiles["default"] - if !ok || profile.APIKey == "" { - return - } + for profileName, profile := range config.Profiles { + if profile.APIKey == "" { + continue + } - out.AddCandidate(sdk.ImportCandidate{ - Fields: map[sdk.FieldName]string{ - fieldname.APIKey: profile.APIKey, - }, - }) + out.AddCandidate(sdk.ImportCandidate{ + Fields: map[sdk.FieldName]string{ + fieldname.APIKey: profile.APIKey, + }, + NameHint: importer.SanitizeNameHint(profileName), + }) + } }) } + From ece89c0983d7000befc907e5d6e8863c8391af4c Mon Sep 17 00:00:00 2001 From: Smyja Date: Wed, 28 Jun 2023 11:29:10 +0100 Subject: [PATCH 16/27] added provision input Signed-off-by: Smyja --- plugins/render/api_key.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/render/api_key.go b/plugins/render/api_key.go index 9a77d35e7..96d956496 100644 --- a/plugins/render/api_key.go +++ b/plugins/render/api_key.go @@ -48,7 +48,14 @@ func APIKey() schema.CredentialType { } func renderConfig(in sdk.ProvisionInput) ([]byte, error) { - config := Config{} + config := Config{ + Profiles: map[string]Profile{ + "default": { + APIKey: in.ItemFields[fieldname.APIKey], + }, + }, + } + contents, err := yaml.Marshal(&config) if err != nil { return nil, err From 3baab321c031038d45cbb5cb0b38f483b46135ca Mon Sep 17 00:00:00 2001 From: Smyja Date: Thu, 29 Jun 2023 09:44:07 +0100 Subject: [PATCH 17/27] removed todo Signed-off-by: Smyja --- plugins/render/api_key_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/render/api_key_test.go b/plugins/render/api_key_test.go index 6a8d761ae..dee15bf84 100644 --- a/plugins/render/api_key_test.go +++ b/plugins/render/api_key_test.go @@ -11,7 +11,7 @@ import ( func TestAPIKeyProvisioner(t *testing.T) { plugintest.TestProvisioner(t, APIKey().DefaultProvisioner, map[string]plugintest.ProvisionCase{ "default": { - ItemFields: map[sdk.FieldName]string{ // TODO: Check if this is correct + ItemFields: map[sdk.FieldName]string{ fieldname.APIKey: "rnd_Z7xMKp4NX1FoQNRyBpZs9yxDbu3i", }, }, From c6648b90b0aaf65bfe7ee539113e279abb487ecf Mon Sep 17 00:00:00 2001 From: Smyja Date: Thu, 29 Jun 2023 09:47:37 +0100 Subject: [PATCH 18/27] removed importer.TryAll Signed-off-by: Smyja --- plugins/render/api_key.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/render/api_key.go b/plugins/render/api_key.go index 96d956496..413ed491a 100644 --- a/plugins/render/api_key.go +++ b/plugins/render/api_key.go @@ -41,9 +41,7 @@ func APIKey() schema.CredentialType { }, }, DefaultProvisioner: provision.TempFile(renderConfig, provision.AtFixedPath(ConfigPath())), - Importer: importer.TryAll( - TryRenderConfigFile(), - ), + Importer: TryRenderConfigFile(), } } From e01358f3a1fe034c8cf18accb935cbfc26171124 Mon Sep 17 00:00:00 2001 From: Smyja Date: Thu, 29 Jun 2023 09:51:57 +0100 Subject: [PATCH 19/27] removed configpath function Signed-off-by: Smyja --- plugins/render/api_key.go | 2 +- plugins/render/render.go | 9 --------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/plugins/render/api_key.go b/plugins/render/api_key.go index 413ed491a..ea34eecf9 100644 --- a/plugins/render/api_key.go +++ b/plugins/render/api_key.go @@ -40,7 +40,7 @@ func APIKey() schema.CredentialType { }, }, }, - DefaultProvisioner: provision.TempFile(renderConfig, provision.AtFixedPath(ConfigPath())), + DefaultProvisioner: provision.TempFile(renderConfig, provision.AtFixedPath("~/.render/config.yaml")), Importer: TryRenderConfigFile(), } } diff --git a/plugins/render/render.go b/plugins/render/render.go index 2935f68b0..faed362c0 100644 --- a/plugins/render/render.go +++ b/plugins/render/render.go @@ -5,17 +5,8 @@ import ( "github.com/1Password/shell-plugins/sdk/needsauth" "github.com/1Password/shell-plugins/sdk/schema" "github.com/1Password/shell-plugins/sdk/schema/credname" - "os" ) -func ConfigPath() string { - configDir, err := os.UserConfigDir() - if err != nil { - return "~/.render/config.yaml" - } - return configDir + "/render/config.yaml" -} - func RenderCLI() schema.Executable { return schema.Executable{ Name: "Render CLI", From 56aa1f3087d7cea70158e4b1fc1acb1678871d1e Mon Sep 17 00:00:00 2001 From: Smyja Date: Thu, 29 Jun 2023 10:06:34 +0100 Subject: [PATCH 20/27] Api key importer test Signed-off-by: Smyja --- plugins/render/api_key_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/plugins/render/api_key_test.go b/plugins/render/api_key_test.go index dee15bf84..fd03afa31 100644 --- a/plugins/render/api_key_test.go +++ b/plugins/render/api_key_test.go @@ -17,3 +17,21 @@ func TestAPIKeyProvisioner(t *testing.T) { }, }) } + + +func TestAPIKeyImporter(t *testing.T) { + plugintest.TestImporter(t, APIKey().Importer, map[string]plugintest.ImportCase{ + "config file": { + Files: map[string]string{ + "~/.render/config.yaml": plugintest.LoadFixture(t, "config.yaml"), + }, + ExpectedCandidates: []sdk.ImportCandidate{ + { + Fields: map[sdk.FieldName]string{ + fieldname.APIKey: "rnd_Z7xMKp4NX1FoQNRyBpZs9yxDbu3i", + }, + }, + }, + }, + }) +} From c4374ad782d1fb8a036aaf265e9d6e538adbf072 Mon Sep 17 00:00:00 2001 From: Smyja Date: Thu, 29 Jun 2023 10:43:12 +0100 Subject: [PATCH 21/27] updated needsauth Signed-off-by: Smyja --- plugins/render/render.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/render/render.go b/plugins/render/render.go index faed362c0..aa4305f81 100644 --- a/plugins/render/render.go +++ b/plugins/render/render.go @@ -15,6 +15,11 @@ func RenderCLI() schema.Executable { NeedsAuth: needsauth.IfAll( needsauth.NotForHelpOrVersion(), needsauth.NotWithoutArgs(), + needsauth.NotWhenContainsArgs("config"), + needsauth.NotWhenContainsArgs("jobs"), + needsauth.NotWhenContainsArgs("deploys"), + needsauth.NotWhenContainsArgs("repo"), + needsauth.NotWhenContainsArgs("services"), ), Uses: []schema.CredentialUsage{ { From 546358b1e490448fa03f22bca04e690d092a5621 Mon Sep 17 00:00:00 2001 From: Smyja Date: Thu, 29 Jun 2023 12:09:39 +0100 Subject: [PATCH 22/27] config.yml Signed-off-by: Smyja --- plugins/render/test-fixtures/config.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 plugins/render/test-fixtures/config.yaml diff --git a/plugins/render/test-fixtures/config.yaml b/plugins/render/test-fixtures/config.yaml new file mode 100644 index 000000000..b82052912 --- /dev/null +++ b/plugins/render/test-fixtures/config.yaml @@ -0,0 +1,6 @@ +version: 1 +sshPreserveHosts: true +profiles: + default: + defaultRegion: oregon + apiKey: rnd_Z7xMKp4NX1FoQNRyBpZs9yxDbu3i \ No newline at end of file From afef4aa40a25e5d11362ffd3f4a20406b3f81383 Mon Sep 17 00:00:00 2001 From: Smyja Date: Thu, 29 Jun 2023 12:35:03 +0100 Subject: [PATCH 23/27] update Signed-off-by: Smyja --- plugins/render/api_key_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/render/api_key_test.go b/plugins/render/api_key_test.go index fd03afa31..50ef14be9 100644 --- a/plugins/render/api_key_test.go +++ b/plugins/render/api_key_test.go @@ -14,7 +14,15 @@ func TestAPIKeyProvisioner(t *testing.T) { ItemFields: map[sdk.FieldName]string{ fieldname.APIKey: "rnd_Z7xMKp4NX1FoQNRyBpZs9yxDbu3i", }, + ExpectedOutput: sdk.ProvisionOutput{ + Files: map[string]sdk.OutputFile{ + ConfigPath(): { + Contents: []byte(plugintest.LoadFixture(t, "config.yaml")), + }, + }, + }, }, + }) } From a695a2e63c8ac9f176a129a4d4c96f71d0af92b4 Mon Sep 17 00:00:00 2001 From: Smyja Date: Thu, 29 Jun 2023 12:42:38 +0100 Subject: [PATCH 24/27] updated test Signed-off-by: Smyja --- plugins/render/api_key_test.go | 2 +- plugins/render/test-fixtures/config.yaml | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/plugins/render/api_key_test.go b/plugins/render/api_key_test.go index 50ef14be9..81b9edd09 100644 --- a/plugins/render/api_key_test.go +++ b/plugins/render/api_key_test.go @@ -16,7 +16,7 @@ func TestAPIKeyProvisioner(t *testing.T) { }, ExpectedOutput: sdk.ProvisionOutput{ Files: map[string]sdk.OutputFile{ - ConfigPath(): { + "~/.render/config.yaml":{ Contents: []byte(plugintest.LoadFixture(t, "config.yaml")), }, }, diff --git a/plugins/render/test-fixtures/config.yaml b/plugins/render/test-fixtures/config.yaml index b82052912..a3e4bcf0e 100644 --- a/plugins/render/test-fixtures/config.yaml +++ b/plugins/render/test-fixtures/config.yaml @@ -1,6 +1 @@ -version: 1 -sshPreserveHosts: true -profiles: - default: - defaultRegion: oregon - apiKey: rnd_Z7xMKp4NX1FoQNRyBpZs9yxDbu3i \ No newline at end of file +apiKey: rnd_Z7xMKp4NX1FoQNRyBpZs9yxDbu3i \ No newline at end of file From 8bb79139b1340eb043f23f89bef36cb52c82cc8e Mon Sep 17 00:00:00 2001 From: Smyja Date: Thu, 29 Jun 2023 12:48:45 +0100 Subject: [PATCH 25/27] formatted files Signed-off-by: Smyja --- plugins/render/api_key.go | 5 ++--- plugins/render/api_key_test.go | 4 +--- plugins/render/test-fixtures/config.yaml | 4 +++- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/render/api_key.go b/plugins/render/api_key.go index ea34eecf9..408a7cba8 100644 --- a/plugins/render/api_key.go +++ b/plugins/render/api_key.go @@ -41,7 +41,7 @@ func APIKey() schema.CredentialType { }, }, DefaultProvisioner: provision.TempFile(renderConfig, provision.AtFixedPath("~/.render/config.yaml")), - Importer: TryRenderConfigFile(), + Importer: TryRenderConfigFile(), } } @@ -53,7 +53,7 @@ func renderConfig(in sdk.ProvisionInput) ([]byte, error) { }, }, } - + contents, err := yaml.Marshal(&config) if err != nil { return nil, err @@ -83,4 +83,3 @@ func TryRenderConfigFile() sdk.Importer { } }) } - diff --git a/plugins/render/api_key_test.go b/plugins/render/api_key_test.go index 81b9edd09..9f746de20 100644 --- a/plugins/render/api_key_test.go +++ b/plugins/render/api_key_test.go @@ -16,17 +16,15 @@ func TestAPIKeyProvisioner(t *testing.T) { }, ExpectedOutput: sdk.ProvisionOutput{ Files: map[string]sdk.OutputFile{ - "~/.render/config.yaml":{ + "~/.render/config.yaml": { Contents: []byte(plugintest.LoadFixture(t, "config.yaml")), }, }, }, }, - }) } - func TestAPIKeyImporter(t *testing.T) { plugintest.TestImporter(t, APIKey().Importer, map[string]plugintest.ImportCase{ "config file": { diff --git a/plugins/render/test-fixtures/config.yaml b/plugins/render/test-fixtures/config.yaml index a3e4bcf0e..71ce598ed 100644 --- a/plugins/render/test-fixtures/config.yaml +++ b/plugins/render/test-fixtures/config.yaml @@ -1 +1,3 @@ -apiKey: rnd_Z7xMKp4NX1FoQNRyBpZs9yxDbu3i \ No newline at end of file +profiles: + default: + apiKey: rnd_Z7xMKp4NX1FoQNRyBpZs9yxDbu3i \ No newline at end of file From 57ffcb6e8dc1645389efefd52827d7086389bdef Mon Sep 17 00:00:00 2001 From: Smyja Date: Thu, 29 Jun 2023 21:44:34 +0100 Subject: [PATCH 26/27] fixed test --- plugins/render/api_key_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/render/api_key_test.go b/plugins/render/api_key_test.go index 9f746de20..f9e49238f 100644 --- a/plugins/render/api_key_test.go +++ b/plugins/render/api_key_test.go @@ -17,7 +17,7 @@ func TestAPIKeyProvisioner(t *testing.T) { ExpectedOutput: sdk.ProvisionOutput{ Files: map[string]sdk.OutputFile{ "~/.render/config.yaml": { - Contents: []byte(plugintest.LoadFixture(t, "config.yaml")), + Contents: []byte(plugintest.LoadFixture(t, "config.yaml")+ "\n"), }, }, }, From 237c7946d9902cfb60bae2f8b28535a7fea49637 Mon Sep 17 00:00:00 2001 From: Smyja Date: Thu, 29 Jun 2023 22:07:03 +0100 Subject: [PATCH 27/27] fixed lint --- plugins/render/api_key_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/render/api_key_test.go b/plugins/render/api_key_test.go index f9e49238f..ced5195bc 100644 --- a/plugins/render/api_key_test.go +++ b/plugins/render/api_key_test.go @@ -17,7 +17,7 @@ func TestAPIKeyProvisioner(t *testing.T) { ExpectedOutput: sdk.ProvisionOutput{ Files: map[string]sdk.OutputFile{ "~/.render/config.yaml": { - Contents: []byte(plugintest.LoadFixture(t, "config.yaml")+ "\n"), + Contents: []byte(plugintest.LoadFixture(t, "config.yaml") + "\n"), }, }, },