Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VPC key create and delete operations added #1085

Closed
wants to merge 7 commits into from

Conversation

Madhan-SWE
Copy link
Contributor

@Madhan-SWE Madhan-SWE commented Feb 8, 2023

What this PR does / why we need it:
This is for creating and deleting key from VPC.

Create key

%./capibmadm vpc key create --name test-key --key-path /Users/madhankumar/.ssh/id_rsa.pub --region eu-de 

VPC Key created successfully, key-name="test-key"
% ./capibmadm vpc key create  --name test-key --public-key "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDHeTZS7Pxr/43AG1Z0rVktiisut+XTqODsZMBFwJX3AJUmp4K21GzOYaBYreAIAZht36I7Qw8Kv5QtqMDcZl00dkQZBHR4Gs7fQUpjZh5z6yDSm2v5SjUf7POk3kixEbyUuE1o0Hik0acaEk/18r09FHuelSsB2UvaBDjbF/1EMzrgHJ8LgnH9Md+Y/I6fb4NE3Jryrs20rC5pTxCkzX2K7NYo1oduv9pkGA2tAdukCFPgX0HjXdYP1h54MJxWU/EtMgjz85HjrWH0NYrQEV+uyh1RiBeDKRzBtqqXguXIomZhB2k0WdMPSNM5G/tkXXCM1aO1ZgCzfrn1mP1xp+gzBSjTJi5oX2KPsffP5oyTd09XRWjsjcbAUZEYbcRi8dV3CwtGB8vPFqWtzoE0NUkGTe+e+y81sEPbbikUt9PM+8MQmVDzSEfxYFVem8CJfCRkE3/egfkOP4cRo+px3y4nQngJoKDmuJHjs3BbcgZNxDBCNA44FMgxhaxEUgNkkjM= [email protected]" --region "eu-de"

VPC Key created successfully, key-name="test-key"

Delete key

% ./capibmadm vpc key delete --name test-key --region eu-de

VPC Key deleted succssfully, key-name="test-key"

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

/area provider/ibmcloud

  1. Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

Release note:


@k8s-ci-robot k8s-ci-robot added the area/provider/ibmcloud Issues or PRs related to ibmcloud provider label Feb 8, 2023
@netlify
Copy link

netlify bot commented Feb 8, 2023

Deploy Preview for kubernetes-sigs-cluster-api-ibmcloud ready!

Name Link
🔨 Latest commit 2073ae9
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-ibmcloud/deploys/63f4644f2a5c180008ec57f6
😎 Deploy Preview https://deploy-preview-1085--kubernetes-sigs-cluster-api-ibmcloud.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 8, 2023
@Madhan-SWE Madhan-SWE force-pushed the vpc-key-create branch 2 times, most recently from 22f635e to ea49055 Compare February 9, 2023 04:29
@Karthik-K-N
Copy link
Contributor

Could you please refer to Power VS key command PR: #1087 and make the necessary changes to make it similar.

Also docs are missing in the PR.

@Prajyot-Parab
Copy link
Contributor

@Madhan-SWE Need to update docs here - Doc ref
For more info, you can refer to Kishen's PR, reach out to me for any queries

@k8s-ci-robot
Copy link
Contributor

@Prajyot-Parab: GitHub didn't allow me to request PR reviews from the following users: dharaneeshvrd.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

capibmadm vpc key create --name <key-name> --region <region> --resource-group-name <resource-group-name>

/cc @Karthik-K-N @dharaneeshvrd

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot
Copy link
Contributor

@Prajyot-Parab: GitHub didn't allow me to request PR reviews from the following users: dharaneeshvrd.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

capibmadm vpc key delete --name <key-name> --region <region>`,

lets take key name as input via flag.

/cc @Karthik-K-N @dharaneeshvrd

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.


func deleteKey(keyDeleteOption keyDeleteOptions) error {
log := logf.Log
v1, err := vpc.NewV1Client(options.GlobalOptions.VPCRegion)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets rename v1 to something more descriptive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v1 is renamed to vpcservice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v1 is rename to vpcClient


func createKey(ctx context.Context, keyCreateOption keyCreateOptions) error {
log := logf.Log
v1, err := vpc.NewV1Client(options.GlobalOptions.VPCRegion)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets rename v1 to something more descriptive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v1 is renamed to vpcservice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v1 is rename to vpcClient

# Create key in VPC
export IBMCLOUD_API_KEY=<api-key>
capibmadm vpc key create --name <key-name> --region <region> --resource-group-name <resource-group-name>
--public-key <public-key-string> `,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be withing quotations right, like --public-key-string ""

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.
can we represent like this?

--public-key "<public-key-string>"

any suggestions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@Karthik-K-N Karthik-K-N Feb 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we need to represent like

--public-key "<public-key-string>"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

options.AddCommonFlags(cmd)
var keyCreateOption keyCreateOptions
cmd.Flags().StringVar(&keyCreateOption.name, "name", keyCreateOption.name, "Key Name")
cmd.Flags().StringVar(&keyCreateOption.resourceGroupName, "resource-group-name", keyCreateOption.resourceGroupName, "IBM cloud resource group name")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resource-group-name flag is already available under vpc: https://github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/blob/main/cmd/capibmadm/cmd/vpc/vpc.go#L34, so we can remove it from here


func createKey(ctx context.Context, keyCreateOption keyCreateOptions) error {
log := logf.Log
vpcservice, err := vpc.NewV1Client(options.GlobalOptions.VPCRegion)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets name is as vpcService.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Karthik-K-N how about vpcClient or vpcClientService?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel vpcClient would be better.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, we can go ahead with vpcClient,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v1 is renamed to vpcClient


key, _, err := vpcservice.CreateKey(options)
if err == nil {
log.Info("VPC Key created successfully,", "key id", *key.ID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better we log key name instead ID,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}

if keyID == "" {
return fmt.Errorf("key with the specified name could not be found")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Errorf("key with the specified name could not be found")
return fmt.Errorf("specified key %s could not be found", keyDeleteOption.name)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


_, err = vpcservice.DeleteKey(options)
if err == nil {
log.Info("VPC Key deleted succssfully, ", " key name", keyDeleteOption.name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets remove empty spaces and lets change "key name" to "key-name"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@Prajyot-Parab
Copy link
Contributor

/test all

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 10, 2023
@Madhan-SWE Madhan-SWE force-pushed the vpc-key-create branch 2 times, most recently from 7c79eb8 to 3c57e47 Compare February 10, 2023 09:08
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 10, 2023
@Prajyot-Parab
Copy link
Contributor

@Madhan-SWE please fix the conflicts.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 14, 2023
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 15, 2023
Copy link
Contributor

@Prajyot-Parab Prajyot-Parab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 15, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Madhan-SWE, Prajyot-Parab
Once this PR has been reviewed and has the lgtm label, please assign mkumatag for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

cmd/capibmadm/cmd/vpc/key/doc.go Outdated Show resolved Hide resolved
cmd/capibmadm/cmd/vpc/key/create.go Outdated Show resolved Hide resolved
cmd/capibmadm/cmd/vpc/key/create.go Outdated Show resolved Hide resolved
cmd/capibmadm/cmd/vpc/key/delete.go Outdated Show resolved Hide resolved
cmd/capibmadm/cmd/vpc/key/delete.go Outdated Show resolved Hide resolved
cmd/capibmadm/cmd/vpc/key/delete.go Outdated Show resolved Hide resolved
cmd/capibmadm/cmd/vpc/key/delete.go Outdated Show resolved Hide resolved
Co-authored-by: Manjunath Kumatagi <[email protected]>
Co-authored-by: Prajyot Parab <[email protected]>
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 20, 2023
@Madhan-SWE
Copy link
Contributor Author

This PR contains merge commits which can cause rebasing issues. Created a new PR with all the required changes in a single commit : #1113

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 1, 2023
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@Madhan-SWE
Copy link
Contributor Author

/close

@k8s-ci-robot
Copy link
Contributor

@Madhan-SWE: Closed this PR.

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/provider/ibmcloud Issues or PRs related to ibmcloud provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants