Skip to content

Commit d713a65

Browse files
CLOUDP-329197: Added --skipSignatureVerification flag to plugin install/update (#4025)
1 parent 1a8e42d commit d713a65

File tree

6 files changed

+35
-6
lines changed

6 files changed

+35
-6
lines changed

docs/command/atlas-plugin-install.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ Options
6868
-
6969
- false
7070
- help for install
71+
* - --skipSignatureVerification
72+
-
73+
- false
74+
- Skip signature verification.
7175

7276
Inherited Options
7377
-----------------

docs/command/atlas-plugin-update.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ Options
6969
-
7070
- false
7171
- help for update
72+
* - --skipSignatureVerification
73+
-
74+
- false
75+
- Skip signature verification.
7276

7377
Inherited Options
7478
-----------------

internal/cli/plugin/install.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import (
2222
"github.com/google/go-github/v61/github"
2323
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli"
2424
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/cli/require"
25+
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/flag"
2526
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/plugin"
27+
"github.com/mongodb/mongodb-atlas-cli/atlascli/internal/usage"
2628
"github.com/spf13/cobra"
2729
)
2830

@@ -31,8 +33,9 @@ type InstallOpts struct {
3133
cli.PreRunOpts
3234
cli.OutputOpts
3335
Opts
34-
ghClient *github.Client
35-
githubAsset *GithubAsset
36+
ghClient *github.Client
37+
githubAsset *GithubAsset
38+
skipSignatureVerification bool
3639
}
3740

3841
func (opts *InstallOpts) checkForDuplicatePlugins() error {
@@ -87,6 +90,12 @@ func (opts *InstallOpts) Run(ctx context.Context) error {
8790
return err
8891
}
8992

93+
// When signatureID and pubKeyID are 0, the signature check is skipped.
94+
if opts.skipSignatureVerification {
95+
signatureID = 0
96+
pubKeyID = 0
97+
}
98+
9099
// download plugin asset archive file and save it as ReadCloser
91100
rc, err := opts.githubAsset.getPluginAssetsAsReadCloser(opts.ghClient, assetID, signatureID, pubKeyID)
92101
if err != nil {
@@ -161,5 +170,7 @@ MongoDB provides an example plugin: https://github.com/mongodb/atlas-cli-plugin-
161170
},
162171
}
163172

173+
cmd.Flags().BoolVar(&opts.skipSignatureVerification, flag.SkipSignatureVerification, false, usage.SkipSignatureVerification)
174+
164175
return cmd
165176
}

internal/cli/plugin/update.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ var (
4545
type UpdateOpts struct {
4646
cli.OutputOpts
4747
Opts
48-
UpdateAll bool
49-
pluginSpecifier string
50-
pluginUpdateVersion *semver.Version
51-
ghClient *github.Client
48+
UpdateAll bool
49+
pluginSpecifier string
50+
pluginUpdateVersion *semver.Version
51+
ghClient *github.Client
52+
skipSignatureVerification bool
5253
}
5354

5455
func printPluginUpdateWarning(p *plugin.Plugin, err error) {
@@ -144,6 +145,12 @@ func (opts *UpdateOpts) updatePlugin(ctx context.Context, githubAssetRelease *Gi
144145
return err
145146
}
146147

148+
// When signatureID and pubKeyID are 0, the signature check is skipped.
149+
if opts.skipSignatureVerification {
150+
signatureID = 0
151+
pubKeyID = 0
152+
}
153+
147154
// download plugin asset archive file and save it as ReadCloser
148155
rc, err := githubAssetRelease.getPluginAssetsAsReadCloser(opts.ghClient, assetID, signatureID, pubKeyID)
149156
if err != nil {
@@ -308,6 +315,7 @@ Additionally, you can use the "--all" flag to update all plugins.
308315
}
309316

310317
cmd.Flags().BoolVar(&opts.UpdateAll, flag.All, false, usage.UpdateAllPlugins)
318+
cmd.Flags().BoolVar(&opts.skipSignatureVerification, flag.SkipSignatureVerification, false, usage.SkipSignatureVerification)
311319

312320
return cmd
313321
}

internal/flag/flags.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ const (
303303
FrequencyType = "frequencyType" // FrequencyType flag
304304
FrequencyInterval = "frequencyInterval" // FrequencyInterval flag
305305
All = "all" // All flag
306+
SkipSignatureVerification = "skipSignatureVerification" // SkipSignatureVerification flag
306307
RetentionUnit = "retentionUnit" // RetentionUnit flag
307308
RetentionValue = "retentionValue" // RetentionValue flag
308309
FederationSettingsID = "federationSettingsId" // FederationSettingsId flag

internal/usage/usage.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ dbName and collection are required only for built-in roles.`
231231
ContainerRegion = "Cloud provider region where the VPC that you peered with the Atlas VPC resides."
232232
ContainerRegions = "List of Atlas regions where the container resides."
233233
UpdateAllPlugins = "update all plugins"
234+
SkipSignatureVerification = "Skip signature verification."
234235
ProjectOwnerID = "Unique 24-digit string that identifies the Atlas user to be granted the Project Owner role on the specified project. If unspecified, this value defaults to the user ID of the oldest Organization Owner."
235236
OrgOwnerID = "Unique 24-digit string that identifies the Atlas user to be granted the Org Owner role on the specified organization. Required if using API keys."
236237
GovCloudRegionsOnly = "Flag that designates that the project uses only the AWS GovCloud region. Use this option only for Atlas for Government projects. If unspecified, the project uses only the AWS Standard region for AWS deployments. You can't deploy clusters across AWS GovCloud and AWS Standard regions in the same project."

0 commit comments

Comments
 (0)