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

fix(cluster connect): print access commands separately for services #1327

Merged
merged 4 commits into from
Nov 18, 2021

Conversation

rkpattnaik780
Copy link
Contributor

Display commands required to grant access to the service-account.

Verification Steps

  1. Connect a service registry instance with the cluster:
rhoas cluster connect --service-type service-registry --namespace default -y

It should print command to give access to the the service registry

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation change
  • Other (please specify)

Checklist

  • Documentation added for the feature
  • CI and all relevant tests are passing
  • Code Review completed
  • Verified independently by reviewer

@wtrocki
Copy link
Collaborator

wtrocki commented Nov 17, 2021

Still verifying but code changes look good!

@rkpattnaik780
Copy link
Contributor Author

Still verifying but code changes look good!

One query, things will get tricky when context mode is not used, while we can modify the command for registry, the issue will persist with Kafka.

Copy link
Collaborator

@wtrocki wtrocki left a comment

Choose a reason for hiding this comment

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

Verified. Small improvements needed in messages. Otherwise ok

@wtrocki
Copy link
Collaborator

wtrocki commented Nov 17, 2021

One query, things will get tricky when context mode is not used, while we can modify the command for registry, the issue will persist with Kafka.

Not sure I understand. Is there still some work to be done?

@@ -218,6 +218,8 @@ func (c *KubernetesClusterAPIImpl) createServiceAccountSecretIfNeeded(namespace
localize.NewEntry("ClientID", serviceAcct.GetClientId()),
))

currentService.PrintAccessCommands(serviceAcct.GetClientId())
Copy link
Contributor

Choose a reason for hiding this comment

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

My own feeling is that this does not belong in this package and should be printed from the connect command. This package is a Kubernetes API client and by print stuff to the console it is mixing responsibility layers.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I haven't seen requirement to have this as kube client. I know we have this interface for it but IMHO this is slightly over-designing something that is very tightly related to CLI command. There are many places in services where we do the same, use context etc.
Sole purpose of this package is to serve as execution layer for commands.

Copy link
Contributor

Choose a reason for hiding this comment

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

The thing that highlighted this for me is that we are passing down currentService as a new function argument for the sole purpose of printing the access commands. It does not relate to the core purpose of the function (creating a service when needed) and goes against the single-responsibility principle.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Funny. Rama wanted it this way and I have recomended to do it in function also quoting single responsibility rule (dealing with service accounts)

#opinions :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

@rkpattnaik780 to make final call on this

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, same result at the end of the day :)

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 agree with the method part, have updated the method to return a client ID if service account is created and print from connect command.

pkg/cluster/services/kafka.go Show resolved Hide resolved
@@ -89,11 +89,15 @@ func (api *KubernetesClusterAPIImpl) ExecuteConnect(connectOpts *v1alpha.Connect
return kubeclient.TranslatedKubernetesErrors(api.CommandEnvironment, err)
}

err = api.createServiceAccountSecretIfNeeded(currentNamespace, currentService)
clientID, err := api.createServiceAccountSecretIfNeeded(currentNamespace)
Copy link
Contributor

Choose a reason for hiding this comment

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

:)

@rkpattnaik780 rkpattnaik780 merged commit 79cdd75 into main Nov 18, 2021
@rkpattnaik780 rkpattnaik780 deleted the sr_access_cmds branch November 18, 2021 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants