Skip to content
This repository was archived by the owner on Dec 15, 2021. It is now read-only.

Disable runtime check if has no permissions to do so#992

Merged
andresmgot merged 3 commits intovmware-archive:masterfrom
dimm0:master
Jan 31, 2019
Merged

Disable runtime check if has no permissions to do so#992
andresmgot merged 3 commits intovmware-archive:masterfrom
dimm0:master

Conversation

@dimm0
Copy link
Contributor

@dimm0 dimm0 commented Jan 25, 2019

Issue Ref: [Issue number related to this PR or None]
#989

Description:
In RBAC-restricted cluster user might have no permissions to see cluster-scoped things

[PR Description]
I was not sure whether you still want to leave the warning and do that check.

TODOs:

  • Ready to review
  • Automated Tests
  • Docs

Copy link
Contributor

@andresmgot andresmgot left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @dimm0! I have a small suggestion to make the code a bit safer for others to extend.

if runtime != "" && !lr.IsValidRuntime(runtime) {
logrus.Fatalf("Invalid runtime: %s. Supported runtimes are: %s",
runtime, strings.Join(lr.GetRuntimes(), ", "))
if checkRuntime {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is fine but since config is initialized way above some other function may try to use that variable that may be nil. To make a bit more clear that the config is only used for the runtime check I would move the initialization here:

apiExtensionsClientset := kubelessUtils.GetAPIExtensionsClientOutOfCluster()
config, err := kubelessUtils.GetKubelessConfig(cli, apiExtensionsClientset)
if config != nil {
    lr := langruntime.New(config)
    lr.ReadConfigMap()
    if runtime ...
} else {
    logrus.Warnf("%v. Runtime check is disabled.", err)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@andresmgot Thanks, please look at my changes

Copy link
Contributor

@andresmgot andresmgot left a comment

Choose a reason for hiding this comment

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

Great, thank you for the changes!

@andresmgot andresmgot merged commit 25afd67 into vmware-archive:master Jan 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants