From de1c40e3d59411838aa60257dc3d83ca467d5888 Mon Sep 17 00:00:00 2001 From: William Park Date: Mon, 13 Feb 2023 09:28:39 -0800 Subject: [PATCH 1/8] Created IBM plugin foundation with 'make new-plugin' --- plugins/ibmcloud/api_key.go | 70 ++++++++++++++++++++++++++++++++ plugins/ibmcloud/api_key_test.go | 55 +++++++++++++++++++++++++ plugins/ibmcloud/ibmcloud.go | 25 ++++++++++++ plugins/ibmcloud/plugin.go | 22 ++++++++++ 4 files changed, 172 insertions(+) create mode 100644 plugins/ibmcloud/api_key.go create mode 100644 plugins/ibmcloud/api_key_test.go create mode 100644 plugins/ibmcloud/ibmcloud.go create mode 100644 plugins/ibmcloud/plugin.go diff --git a/plugins/ibmcloud/api_key.go b/plugins/ibmcloud/api_key.go new file mode 100644 index 000000000..ae9c5280f --- /dev/null +++ b/plugins/ibmcloud/api_key.go @@ -0,0 +1,70 @@ +package ibmcloud + +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://ibmcloud.com/docs/api_key"), // TODO: Replace with actual URL + ManagementURL: sdk.URL("https://console.ibmcloud.com/user/security/tokens"), // TODO: Replace with actual URL + Fields: []schema.CredentialField{ + { + Name: fieldname.APIKey, + MarkdownDescription: "API Key used to authenticate to IBM Cloud.", + Secret: true, + Composition: &schema.ValueComposition{ + Length: 44, + Charset: schema.Charset{ + Uppercase: true, + Lowercase: true, + Digits: true, + }, + }, + }, + }, + DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping), + Importer: importer.TryAll( + importer.TryEnvVarPair(defaultEnvVarMapping), + TryIBMCloudConfigFile(), + )} +} + +var defaultEnvVarMapping = map[string]sdk.FieldName{ + "IBMCLOUD_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 TryIBMCloudConfigFile() 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/ibmcloud/api_key_test.go b/plugins/ibmcloud/api_key_test.go new file mode 100644 index 000000000..6a124e861 --- /dev/null +++ b/plugins/ibmcloud/api_key_test.go @@ -0,0 +1,55 @@ +package ibmcloud + +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: "tjLKgtZ5MSkC9zhSVGCeSfbxBbqr7KCbkfFaHEXAMPLE", + }, + ExpectedOutput: sdk.ProvisionOutput{ + Environment: map[string]string{ + "IBMCLOUD_API_KEY": "tjLKgtZ5MSkC9zhSVGCeSfbxBbqr7KCbkfFaHEXAMPLE", + }, + }, + }, + }) +} + +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 + "IBMCLOUD_API_KEY": "tjLKgtZ5MSkC9zhSVGCeSfbxBbqr7KCbkfFaHEXAMPLE", + }, + ExpectedCandidates: []sdk.ImportCandidate{ + { + Fields: map[sdk.FieldName]string{ + fieldname.APIKey: "tjLKgtZ5MSkC9zhSVGCeSfbxBbqr7KCbkfFaHEXAMPLE", + }, + }, + }, + }, + // TODO: If you implemented a config file importer, add a test file example in ibmcloud/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: "tjLKgtZ5MSkC9zhSVGCeSfbxBbqr7KCbkfFaHEXAMPLE", + // }, + // }, + }, + }, + }) +} diff --git a/plugins/ibmcloud/ibmcloud.go b/plugins/ibmcloud/ibmcloud.go new file mode 100644 index 000000000..0ec9dce1e --- /dev/null +++ b/plugins/ibmcloud/ibmcloud.go @@ -0,0 +1,25 @@ +package ibmcloud + +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 IBMCloudCLI() schema.Executable { + return schema.Executable{ + Name: "IBM Cloud CLI", // TODO: Check if this is correct + Runs: []string{"ibmcloud"}, + DocsURL: sdk.URL("https://ibmcloud.com/docs/cli"), // TODO: Replace with actual URL + NeedsAuth: needsauth.IfAll( + needsauth.NotForHelpOrVersion(), + needsauth.NotWithoutArgs(), + ), + Uses: []schema.CredentialUsage{ + { + Name: credname.APIKey, + }, + }, + } +} diff --git a/plugins/ibmcloud/plugin.go b/plugins/ibmcloud/plugin.go new file mode 100644 index 000000000..cd37467d6 --- /dev/null +++ b/plugins/ibmcloud/plugin.go @@ -0,0 +1,22 @@ +package ibmcloud + +import ( + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/schema" +) + +func New() schema.Plugin { + return schema.Plugin{ + Name: "ibmcloud", + Platform: schema.PlatformInfo{ + Name: "IBM Cloud", + Homepage: sdk.URL("https://ibmcloud.com"), // TODO: Check if this is correct + }, + Credentials: []schema.CredentialType{ + APIKey(), + }, + Executables: []schema.Executable{ + IBMCloudCLI(), + }, + } +} From c19712c129a638defe2010dbfd1b8e86b8fb8e41 Mon Sep 17 00:00:00 2001 From: William Park Date: Mon, 13 Feb 2023 11:24:17 -0800 Subject: [PATCH 2/8] Importer and provisioner implementation using API key with basic file importer test --- plugins/ibmcloud/api_key.go | 43 +++++++------- plugins/ibmcloud/api_key_test.go | 22 ++++--- plugins/ibmcloud/ibmcloud.go | 14 +++-- plugins/ibmcloud/plugin.go | 2 +- plugins/ibmcloud/test-fixtures/config.json | 69 ++++++++++++++++++++++ 5 files changed, 110 insertions(+), 40 deletions(-) create mode 100644 plugins/ibmcloud/test-fixtures/config.json diff --git a/plugins/ibmcloud/api_key.go b/plugins/ibmcloud/api_key.go index ae9c5280f..a6e9c1ea8 100644 --- a/plugins/ibmcloud/api_key.go +++ b/plugins/ibmcloud/api_key.go @@ -14,8 +14,8 @@ import ( func APIKey() schema.CredentialType { return schema.CredentialType{ Name: credname.APIKey, - DocsURL: sdk.URL("https://ibmcloud.com/docs/api_key"), // TODO: Replace with actual URL - ManagementURL: sdk.URL("https://console.ibmcloud.com/user/security/tokens"), // TODO: Replace with actual URL + DocsURL: sdk.URL("https://www.ibm.com/docs/en/app-connect/container?topic=servers-creating-cloud-api-key"), + ManagementURL: sdk.URL("https://cloud.ibm.com/iam/apikeys"), Fields: []schema.CredentialField{ { Name: fieldname.APIKey, @@ -39,32 +39,29 @@ func APIKey() schema.CredentialType { } var defaultEnvVarMapping = map[string]sdk.FieldName{ - "IBMCLOUD_API_KEY": fieldname.APIKey, // TODO: Check if this is correct + "IBMCLOUD_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 TryIBMCloudConfigFile() 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("~/.bluemix/config.json", func(ctx context.Context, contents importer.FileContents, in sdk.ImportInput, out *sdk.ImportAttempt) { + var config Config + if err := contents.ToJSON(&config); err != nil { + out.AddError(err) + return + } - // if config.APIKey == "" { - // return - // } + if config.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: config.APIKey, + }, + }) }) } -// TODO: Implement the config file schema -// type Config struct { -// APIKey string -// } +type Config struct { + APIKey string `json:"APIKey"` +} diff --git a/plugins/ibmcloud/api_key_test.go b/plugins/ibmcloud/api_key_test.go index 6a124e861..a9fc5d281 100644 --- a/plugins/ibmcloud/api_key_test.go +++ b/plugins/ibmcloud/api_key_test.go @@ -2,16 +2,16 @@ package ibmcloud 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 + ItemFields: map[sdk.FieldName]string{ fieldname.APIKey: "tjLKgtZ5MSkC9zhSVGCeSfbxBbqr7KCbkfFaHEXAMPLE", }, ExpectedOutput: sdk.ProvisionOutput{ @@ -26,7 +26,7 @@ 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 + Environment: map[string]string{ "IBMCLOUD_API_KEY": "tjLKgtZ5MSkC9zhSVGCeSfbxBbqr7KCbkfFaHEXAMPLE", }, ExpectedCandidates: []sdk.ImportCandidate{ @@ -37,18 +37,16 @@ func TestAPIKeyImporter(t *testing.T) { }, }, }, - // TODO: If you implemented a config file importer, add a test file example in ibmcloud/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"), + "~/.bluemix/config.json": plugintest.LoadFixture(t, "config.json"), }, ExpectedCandidates: []sdk.ImportCandidate{ - // { - // Fields: map[sdk.FieldName]string{ - // fieldname.Token: "tjLKgtZ5MSkC9zhSVGCeSfbxBbqr7KCbkfFaHEXAMPLE", - // }, - // }, + { + Fields: map[sdk.FieldName]string{ + fieldname.APIKey: "tjLKgtZ5MSkC9zhSVGCeSfbxBbqr7KCbkfFaHEXAMPLE", + }, + }, }, }, }) diff --git a/plugins/ibmcloud/ibmcloud.go b/plugins/ibmcloud/ibmcloud.go index 0ec9dce1e..55d44cbfe 100644 --- a/plugins/ibmcloud/ibmcloud.go +++ b/plugins/ibmcloud/ibmcloud.go @@ -9,12 +9,18 @@ import ( func IBMCloudCLI() schema.Executable { return schema.Executable{ - Name: "IBM Cloud CLI", // TODO: Check if this is correct - Runs: []string{"ibmcloud"}, - DocsURL: sdk.URL("https://ibmcloud.com/docs/cli"), // TODO: Replace with actual URL + Name: "IBM Cloud CLI", + Runs: []string{"ibmcloud"}, + DocsURL: sdk.URL("https://cloud.ibm.com/docs/cli"), NeedsAuth: needsauth.IfAll( needsauth.NotForHelpOrVersion(), - needsauth.NotWithoutArgs(), + needsauth.NotWhenContainsArgs("-u"), + needsauth.NotWhenContainsArgs("-p"), + needsauth.NotWhenContainsArgs("--apikey"), + needsauth.NotWhenContainsArgs("--cr-token"), + needsauth.NotWhenContainsArgs("--profile"), + needsauth.NotWhenContainsArgs("--sso"), + needsauth.NotWhenContainsArgs("--no-account"), ), Uses: []schema.CredentialUsage{ { diff --git a/plugins/ibmcloud/plugin.go b/plugins/ibmcloud/plugin.go index cd37467d6..c40623aae 100644 --- a/plugins/ibmcloud/plugin.go +++ b/plugins/ibmcloud/plugin.go @@ -10,7 +10,7 @@ func New() schema.Plugin { Name: "ibmcloud", Platform: schema.PlatformInfo{ Name: "IBM Cloud", - Homepage: sdk.URL("https://ibmcloud.com"), // TODO: Check if this is correct + Homepage: sdk.URL("https://www.ibm.com/cloud"), }, Credentials: []schema.CredentialType{ APIKey(), diff --git a/plugins/ibmcloud/test-fixtures/config.json b/plugins/ibmcloud/test-fixtures/config.json new file mode 100644 index 000000000..3457db4a8 --- /dev/null +++ b/plugins/ibmcloud/test-fixtures/config.json @@ -0,0 +1,69 @@ +{ + "APIEndpoint": "https://cloud.ibm.com", + "APIKey": "tjLKgtZ5MSkC9zhSVGCeSfbxBbqr7KCbkfFaHEXAMPLE", + "IsPrivate": false, + "IsAccessFromVPC": false, + "ConsoleEndpoint": "https://cloud.ibm.com", + "ConsolePrivateEndpoint": "", + "ConsolePrivateVPCEndpoint": "", + "CloudType": "public", + "CloudName": "bluemix", + "CRIType": "", + "Region": "", + "RegionID": "", + "IAMEndpoint": "https://iam.cloud.ibm.com", + "IAMPrivateEndpoint": "", + "IAMPrivateVPCEndpoint": "", + "IAMToken": "", + "IAMRefreshToken": "", + "IsLoggedInAsCRI": false, + "Account": { + "GUID": "", + "Name": "", + "Owner": "" + }, + "Profile": { + "ID": "", + "Name": "", + "ComputeResource": { + "Name": "", + "ID": "" + }, + "User": { + "Name": "", + "ID": "" + } + }, + "ResourceGroup": { + "GUID": "", + "Name": "", + "State": "", + "Default": false, + "QuotaID": "" + }, + "LoginAt": "0001-01-01T00:00:00Z", + "CFEETargeted": false, + "CFEEEnvID": "", + "PluginRepos": [ + { + "Name": "IBM Cloud", + "URL": "https://plugins.cloud.ibm.com" + } + ], + "SSLDisabled": false, + "Locale": "", + "MessageOfTheDayTime": 0, + "LastSessionUpdateTime": 0, + "Trace": "", + "ColorEnabled": "", + "HTTPTimeout": 0, + "CLIInfoEndpoint": "", + "CheckCLIVersionDisabled": false, + "UsageStatsDisabled": false, + "UsageStatsEnabled": false, + "UsageStatsEnabledLastUpdate": "0001-01-01T00:00:00Z", + "SDKVersion": "1.0.0", + "UpdateCheckInterval": 0, + "UpdateRetryCheckInterval": 0, + "UpdateNotificationInterval": 0 +} \ No newline at end of file From c95f3b2c16955095ac67d8cd032beb5e2849bb89 Mon Sep 17 00:00:00 2001 From: William Park Date: Mon, 13 Feb 2023 16:09:01 -0800 Subject: [PATCH 3/8] Skip authentication when no arguments are passed --- plugins/ibmcloud/ibmcloud.go | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/ibmcloud/ibmcloud.go b/plugins/ibmcloud/ibmcloud.go index 55d44cbfe..048a991d7 100644 --- a/plugins/ibmcloud/ibmcloud.go +++ b/plugins/ibmcloud/ibmcloud.go @@ -14,6 +14,7 @@ func IBMCloudCLI() schema.Executable { DocsURL: sdk.URL("https://cloud.ibm.com/docs/cli"), NeedsAuth: needsauth.IfAll( needsauth.NotForHelpOrVersion(), + needsauth.NotWithoutArgs(), needsauth.NotWhenContainsArgs("-u"), needsauth.NotWhenContainsArgs("-p"), needsauth.NotWhenContainsArgs("--apikey"), From 273764b922489dd8dd28b648e78795c5a43d9a71 Mon Sep 17 00:00:00 2001 From: William Park Date: Mon, 13 Feb 2023 16:18:05 -0800 Subject: [PATCH 4/8] Authenticate when --no-account flag is passed --- plugins/ibmcloud/ibmcloud.go | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/ibmcloud/ibmcloud.go b/plugins/ibmcloud/ibmcloud.go index 048a991d7..e3add9c23 100644 --- a/plugins/ibmcloud/ibmcloud.go +++ b/plugins/ibmcloud/ibmcloud.go @@ -21,7 +21,6 @@ func IBMCloudCLI() schema.Executable { needsauth.NotWhenContainsArgs("--cr-token"), needsauth.NotWhenContainsArgs("--profile"), needsauth.NotWhenContainsArgs("--sso"), - needsauth.NotWhenContainsArgs("--no-account"), ), Uses: []schema.CredentialUsage{ { From 2d9473d9bdda9a908da9191ed1eb47aa5e133ccf Mon Sep 17 00:00:00 2001 From: William Park Date: Mon, 13 Feb 2023 16:29:25 -0800 Subject: [PATCH 5/8] Add additional no auth rules for flags --- plugins/ibmcloud/ibmcloud.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/ibmcloud/ibmcloud.go b/plugins/ibmcloud/ibmcloud.go index e3add9c23..829dd7b7e 100644 --- a/plugins/ibmcloud/ibmcloud.go +++ b/plugins/ibmcloud/ibmcloud.go @@ -19,8 +19,11 @@ func IBMCloudCLI() schema.Executable { needsauth.NotWhenContainsArgs("-p"), needsauth.NotWhenContainsArgs("--apikey"), needsauth.NotWhenContainsArgs("--cr-token"), + needsauth.NotWhenContainsArgs("--vpc-cri"), needsauth.NotWhenContainsArgs("--profile"), needsauth.NotWhenContainsArgs("--sso"), + needsauth.NotWhenContainsArgs("-c"), + needsauth.NotWhenContainsArgs("--no-account"), ), Uses: []schema.CredentialUsage{ { From 17a58a7fca77da8da2cb855df5dde4c18cafb841 Mon Sep 17 00:00:00 2001 From: William Park Date: Tue, 14 Feb 2023 08:15:31 -0800 Subject: [PATCH 6/8] Update API key docs URL --- plugins/ibmcloud/api_key.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ibmcloud/api_key.go b/plugins/ibmcloud/api_key.go index a6e9c1ea8..d6557bcd2 100644 --- a/plugins/ibmcloud/api_key.go +++ b/plugins/ibmcloud/api_key.go @@ -14,7 +14,7 @@ import ( func APIKey() schema.CredentialType { return schema.CredentialType{ Name: credname.APIKey, - DocsURL: sdk.URL("https://www.ibm.com/docs/en/app-connect/container?topic=servers-creating-cloud-api-key"), + DocsURL: sdk.URL("https://cloud.ibm.com/docs/account?topic=account-userapikey"), ManagementURL: sdk.URL("https://cloud.ibm.com/iam/apikeys"), Fields: []schema.CredentialField{ { From 9102de30eed64a3863b1241021c277e241a56d0d Mon Sep 17 00:00:00 2001 From: William Park Date: Tue, 14 Feb 2023 08:17:39 -0800 Subject: [PATCH 7/8] Skip auth for logout command --- plugins/ibmcloud/ibmcloud.go | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/ibmcloud/ibmcloud.go b/plugins/ibmcloud/ibmcloud.go index 829dd7b7e..97544f382 100644 --- a/plugins/ibmcloud/ibmcloud.go +++ b/plugins/ibmcloud/ibmcloud.go @@ -24,6 +24,7 @@ func IBMCloudCLI() schema.Executable { needsauth.NotWhenContainsArgs("--sso"), needsauth.NotWhenContainsArgs("-c"), needsauth.NotWhenContainsArgs("--no-account"), + needsauth.NotWhenContainsArgs("logout"), ), Uses: []schema.CredentialUsage{ { From 6533c1a8503aa66d279b476d00aa9a62a56730c0 Mon Sep 17 00:00:00 2001 From: William Park Date: Tue, 14 Feb 2023 09:28:32 -0800 Subject: [PATCH 8/8] Removed ibmcloud file importer code --- plugins/ibmcloud/api_key.go | 27 --------- plugins/ibmcloud/api_key_test.go | 12 ---- plugins/ibmcloud/test-fixtures/config.json | 69 ---------------------- 3 files changed, 108 deletions(-) delete mode 100644 plugins/ibmcloud/test-fixtures/config.json diff --git a/plugins/ibmcloud/api_key.go b/plugins/ibmcloud/api_key.go index d6557bcd2..7853d95cd 100644 --- a/plugins/ibmcloud/api_key.go +++ b/plugins/ibmcloud/api_key.go @@ -1,8 +1,6 @@ package ibmcloud import ( - "context" - "github.com/1Password/shell-plugins/sdk" "github.com/1Password/shell-plugins/sdk/importer" "github.com/1Password/shell-plugins/sdk/provision" @@ -34,34 +32,9 @@ func APIKey() schema.CredentialType { DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping), Importer: importer.TryAll( importer.TryEnvVarPair(defaultEnvVarMapping), - TryIBMCloudConfigFile(), )} } var defaultEnvVarMapping = map[string]sdk.FieldName{ "IBMCLOUD_API_KEY": fieldname.APIKey, } - -func TryIBMCloudConfigFile() sdk.Importer { - return importer.TryFile("~/.bluemix/config.json", func(ctx context.Context, contents importer.FileContents, in sdk.ImportInput, out *sdk.ImportAttempt) { - var config Config - if err := contents.ToJSON(&config); err != nil { - out.AddError(err) - return - } - - if config.APIKey == "" { - return - } - - out.AddCandidate(sdk.ImportCandidate{ - Fields: map[sdk.FieldName]string{ - fieldname.APIKey: config.APIKey, - }, - }) - }) -} - -type Config struct { - APIKey string `json:"APIKey"` -} diff --git a/plugins/ibmcloud/api_key_test.go b/plugins/ibmcloud/api_key_test.go index a9fc5d281..064dc146f 100644 --- a/plugins/ibmcloud/api_key_test.go +++ b/plugins/ibmcloud/api_key_test.go @@ -37,17 +37,5 @@ func TestAPIKeyImporter(t *testing.T) { }, }, }, - "config file": { - Files: map[string]string{ - "~/.bluemix/config.json": plugintest.LoadFixture(t, "config.json"), - }, - ExpectedCandidates: []sdk.ImportCandidate{ - { - Fields: map[sdk.FieldName]string{ - fieldname.APIKey: "tjLKgtZ5MSkC9zhSVGCeSfbxBbqr7KCbkfFaHEXAMPLE", - }, - }, - }, - }, }) } diff --git a/plugins/ibmcloud/test-fixtures/config.json b/plugins/ibmcloud/test-fixtures/config.json deleted file mode 100644 index 3457db4a8..000000000 --- a/plugins/ibmcloud/test-fixtures/config.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "APIEndpoint": "https://cloud.ibm.com", - "APIKey": "tjLKgtZ5MSkC9zhSVGCeSfbxBbqr7KCbkfFaHEXAMPLE", - "IsPrivate": false, - "IsAccessFromVPC": false, - "ConsoleEndpoint": "https://cloud.ibm.com", - "ConsolePrivateEndpoint": "", - "ConsolePrivateVPCEndpoint": "", - "CloudType": "public", - "CloudName": "bluemix", - "CRIType": "", - "Region": "", - "RegionID": "", - "IAMEndpoint": "https://iam.cloud.ibm.com", - "IAMPrivateEndpoint": "", - "IAMPrivateVPCEndpoint": "", - "IAMToken": "", - "IAMRefreshToken": "", - "IsLoggedInAsCRI": false, - "Account": { - "GUID": "", - "Name": "", - "Owner": "" - }, - "Profile": { - "ID": "", - "Name": "", - "ComputeResource": { - "Name": "", - "ID": "" - }, - "User": { - "Name": "", - "ID": "" - } - }, - "ResourceGroup": { - "GUID": "", - "Name": "", - "State": "", - "Default": false, - "QuotaID": "" - }, - "LoginAt": "0001-01-01T00:00:00Z", - "CFEETargeted": false, - "CFEEEnvID": "", - "PluginRepos": [ - { - "Name": "IBM Cloud", - "URL": "https://plugins.cloud.ibm.com" - } - ], - "SSLDisabled": false, - "Locale": "", - "MessageOfTheDayTime": 0, - "LastSessionUpdateTime": 0, - "Trace": "", - "ColorEnabled": "", - "HTTPTimeout": 0, - "CLIInfoEndpoint": "", - "CheckCLIVersionDisabled": false, - "UsageStatsDisabled": false, - "UsageStatsEnabled": false, - "UsageStatsEnabledLastUpdate": "0001-01-01T00:00:00Z", - "SDKVersion": "1.0.0", - "UpdateCheckInterval": 0, - "UpdateRetryCheckInterval": 0, - "UpdateNotificationInterval": 0 -} \ No newline at end of file