-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support
DeletionProtection
, index configure
command, and bump `go…
…-pinecone` from v0.5.0 -> v1.1.0 (#16) ## Problem Currently the CLI relies on `v0.5.0` of the `go-pinecone` SDK. We've since released `v1.1.0` of `go-pinecone` and would like to bump the dependency within the CLI. `v1.0.0` added `DeletionProtection` for indexes, which wasn't supported in either `index create-pod`, `index create-serverless`, or any of the other index operations. Additionally, while working on this I noticed we don't currently support an `index configure` command. ## Solution - Bump the `go-pinecone` dependency from `v0.5.0` -> `v1.1.0`. There were no major API changes that needed to be accounted for in the CLI because of this update. - Add `deletion_protection` as an optional argument for both `index create-pod` and `index create-serverless` commands. - Print `DeletionProtection` as a part of the `PrintDescribeIndexTable` presenter. - Add new `/command/index/configure.go` command to allow configuring indexes through the CLI. Use the command in `/command/index/cmd.go`. - Fix errors being swallowed when calling `index delete` command. ## Type of Change - [ ] Bug fix (non-breaking change which fixes an issue) - [X] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update - [ ] Infrastructure change (CI configs, etc) - [ ] Non-code change (docs, etc) - [ ] None of the above: (explain here) ## Test Plan CLI functionality should remain largely unchanged. You can pull this branch down and install `goreleaser` to build and test locally: ``` # build CLI locally goreleaser build --single-target --snapshot --clean # login or set-api-key manually ./dist/pinecone_darwin_arm64/pinecone login ./dist/pinecone_darwin_arm64/pinecone config set-api-key "YOUR_API_KEY" # work with indexes ./dist/pinecone_darwin_arm64/pinecone index list ./dist/pinecone_darwin_arm64/pinecone index create-pod -n "test-cli-create-pod" -d 3 -m "cosine" -e "us-east-1-aws" -t "p1.x1" --deletion_protection "enabled" ./dist/pinecone_darwin_arm64/pinecone index configure -n "test-cli-create_pod" -p "disabled" ./dist/pinecone_darwin_arm64/pinecone index describe --name test-cli-create-pod ``` --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1208161607942737
- Loading branch information
1 parent
81f7555
commit a9a6066
Showing
8 changed files
with
156 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package index | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/pinecone-io/cli/internal/pkg/utils/exit" | ||
"github.com/pinecone-io/cli/internal/pkg/utils/msg" | ||
"github.com/pinecone-io/cli/internal/pkg/utils/pcio" | ||
"github.com/pinecone-io/cli/internal/pkg/utils/presenters" | ||
"github.com/pinecone-io/cli/internal/pkg/utils/sdk" | ||
"github.com/pinecone-io/cli/internal/pkg/utils/style" | ||
"github.com/pinecone-io/cli/internal/pkg/utils/text" | ||
"github.com/pinecone-io/go-pinecone/pinecone" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
type configureIndexOptions struct { | ||
name string | ||
podType string | ||
replicas int32 | ||
deletionProtection string | ||
|
||
json bool | ||
} | ||
|
||
func NewConfigureIndexCmd() *cobra.Command { | ||
options := configureIndexOptions{} | ||
|
||
cmd := &cobra.Command{ | ||
Use: "configure", | ||
Short: "Configure an existing index with the specified configuration", | ||
Example: "", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
runConfigureIndexCmd(cmd, options) | ||
}, | ||
} | ||
|
||
// Required flags | ||
cmd.Flags().StringVarP(&options.name, "name", "n", "", "name of index to configure") | ||
|
||
// Optional flags | ||
cmd.Flags().StringVarP(&options.podType, "pod_type", "t", "", "type of pod to use, can only upgrade when configuring") | ||
cmd.Flags().Int32VarP(&options.replicas, "replicas", "r", 0, "replicas of the index to configure") | ||
cmd.Flags().StringVarP(&options.deletionProtection, "deletion_protection", "p", "", "enable or disable deletion protection for the index") | ||
|
||
return cmd | ||
} | ||
|
||
func runConfigureIndexCmd(cmd *cobra.Command, options configureIndexOptions) { | ||
ctx := context.Background() | ||
pc := sdk.NewPineconeClient() | ||
|
||
idx, err := pc.ConfigureIndex(ctx, options.name, pinecone.ConfigureIndexParams{ | ||
PodType: options.podType, | ||
Replicas: options.replicas, | ||
DeletionProtection: pinecone.DeletionProtection(options.deletionProtection), | ||
}) | ||
if err != nil { | ||
msg.FailMsg("Failed to configure index %s: %+v\n", style.Emphasis(options.name), err) | ||
exit.Error(err) | ||
} | ||
if options.json { | ||
text.PrettyPrintJSON(idx) | ||
return | ||
} | ||
|
||
describeCommand := pcio.Sprintf("pinecone index describe --name %s", idx.Name) | ||
msg.SuccessMsg("Index %s configured successfully. Run %s to check status. \n\n", style.Emphasis(idx.Name), style.Code(describeCommand)) | ||
fmt.Printf("Index model on configure return: %+v\n", idx.Spec.Pod) | ||
presenters.PrintDescribeIndexTable(idx) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters