Skip to content

Conversation

@m1kola
Copy link
Contributor

@m1kola m1kola commented Jul 16, 2021

#1595 needs to be merged first.

Adds a simplified constructor for dynamic validator used in the ARO operator.

@github-actions
Copy link

Please rebase pull request.

@github-actions github-actions bot added the needs-rebase branch needs a rebase label Jul 16, 2021
It is a simplified constructor for dynamic validator
used in the ARO operator.
@m1kola m1kola force-pushed the refactor_dynamic_validator branch from 6d2dffc to b4730a8 Compare July 16, 2021 14:54
@github-actions github-actions bot removed the needs-rebase branch needs a rebase label Jul 16, 2021
@m1kola m1kola marked this pull request as ready for review July 16, 2021 15:07
@m1kola m1kola added priority-low Low priority issue or pull request ready-for-review size-small Size small and removed work-in-progress labels Jul 16, 2021
Copy link
Contributor

@troy0820 troy0820 left a comment

Choose a reason for hiding this comment

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

This looks good. I like the separation of the dynamic validator. One quick question about the constructor: subscriptionID is not necessary it seems.

and the necessary clients for the ServicePrincipalValidtor to perform the check in the operator.
Edit: subscriptionID is necessary to create clients from functions in dynamic constructor 👍🏽
Edit 2: The clientset is nil, because the ValidateServicePrincipal doesn't use any of them, so the subscriptionID is not necessary in this constructor.

}, nil
}

func NewServicePrincipalValidator(log *logrus.Entry, azEnv *azureclient.AROEnvironment, subscriptionID string, authorizerType AuthorizerType) (ServicePrincipalValidator, error) {
Copy link
Contributor

@troy0820 troy0820 Jul 16, 2021

Choose a reason for hiding this comment

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

Suggested change
func NewServicePrincipalValidator(log *logrus.Entry, azEnv *azureclient.AROEnvironment, subscriptionID string, authorizerType AuthorizerType) (ServicePrincipalValidator, error) {
func NewServicePrincipalValidator(log *logrus.Entry, azEnv *azureclient.AROEnvironment, authorizerType AuthorizerType) (ServicePrincipalValidator, error) {

We are not using the subscriptionID anywhere in this function. I don't think this is necessary for the constructor.

Is this missing the clients necessary to do the ValidateServicePrincipal check that it had when it was a full dynamic validator?

Copy link
Contributor

@troy0820 troy0820 Jul 16, 2021

Choose a reason for hiding this comment

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

This makes sense, disregard.
Edit: See below comment

Copy link
Contributor

Choose a reason for hiding this comment

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

No, @troy0820, I think you were right. subscriptionID is not used anywhere. It is passed into the function and then it dies.

Copy link
Contributor

@troy0820 troy0820 Jul 16, 2021

Choose a reason for hiding this comment

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

@nilsanderselde The subscriptionID is passed into this constructor to fulfill the functions that create the rest of the dynamic type, it's just not explicitly set because this happens with functions below on the dynamic struct fields.
Edit: I don't believe that it uses these clients, so the subscriptionID isn't necessary.

providers:          features.NewProvidersClient(azEnv, subscriptionID, authorizer),
spComputeUsage:     compute.NewUsageClient(azEnv, subscriptionID, authorizer),
spNetworkUsage:     network.NewUsageClient(azEnv, subscriptionID, authorizer),
permissions:        authorization.NewPermissionsClient(azEnv, subscriptionID, authorizer),
virtualNetworks:    newVirtualNetworksCache(network.NewVirtualNetworksClient(azEnv, subscriptionID, authorizer)),
diskEncryptionSets: compute.NewDiskEncryptionSetsClient(azEnv, subscriptionID, authorizer),

It doesn't need to be explicitly set because the subscriptionID is necessary for the above functions in the creation of this type.

@troy0820 troy0820 dismissed their stale review July 16, 2021 16:34

The subscriptionID is necessary to build the clients to perform the check. 👍🏽

@troy0820 troy0820 added the LGTM Looks Good To Me label Jul 16, 2021
troy0820
troy0820 previously approved these changes Jul 16, 2021
Copy link
Contributor

@troy0820 troy0820 left a comment

Choose a reason for hiding this comment

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

LGTM

@troy0820
Copy link
Contributor

/azp run e2e

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@nilsanderselde nilsanderselde left a comment

Choose a reason for hiding this comment

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

Param subscriptionID is not used anywhere.

@troy0820 troy0820 added question Further information is requested and removed LGTM Looks Good To Me labels Jul 16, 2021
@troy0820 troy0820 dismissed their stale review July 16, 2021 19:11

Needs clarification with @nilsanderselde's question.

@troy0820 troy0820 removed the question Further information is requested label Jul 16, 2021
@mjudeikis mjudeikis merged commit e14233c into Azure:master Jul 19, 2021
@m1kola m1kola deleted the refactor_dynamic_validator branch July 19, 2021 12:08
@m1kola
Copy link
Contributor Author

m1kola commented Jul 19, 2021

PR accidentaly got merged too early. I'm addressing feedback in #1619

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority-low Low priority issue or pull request ready-for-review size-small Size small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants