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

Clarify router cmd ignoreError comments #15907

Merged
merged 1 commit into from
Aug 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pkg/oc/admin/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ func RunCmdRouter(f *clientcmd.Factory, cmd *cobra.Command, out, errout io.Write
}

levelPrefixFilter := func(e error) string {
// ignore SA/RB errors if we were creating the service account
// Avoid failing when service accounts or role bindings already exist.
if ignoreError(e, cfg.ServiceAccount, generateRoleBindingName(cfg.Name)) {
return "warning"
}
Expand All @@ -849,8 +849,8 @@ func RunCmdRouter(f *clientcmd.Factory, cmd *cobra.Command, out, errout io.Write
}

// ignoreError will return true if the error is an already exists status error and
// 1. it is for a cluster role binding named roleBindingName
// 2. it is for a serivce account name saName
// 1. it is for a cluster role binding named roleBindingName, or
// 2. it is for a service account name saName
func ignoreError(e error, saName string, roleBindingName string) bool {
if !errors.IsAlreadyExists(e) {
return false
Expand All @@ -864,8 +864,8 @@ func ignoreError(e error, saName string, roleBindingName string) bool {
return false
}
return (details.Kind == "serviceaccounts" && details.Name == saName) ||
(details.Kind == "clusterrolebinding" && details.Name == roleBindingName) ||
(details.Kind == "clusterrolebindings" && details.Name == roleBindingName) // TODO we should not need to do this
(details.Kind == "clusterrolebinding" /*pre-3.7*/ && details.Name == roleBindingName) ||
(details.Kind == "clusterrolebindings" /*3.7+*/ && details.Name == roleBindingName)
}

// generateRoleBindingName generates a name for the rolebinding object if it is
Expand Down