Skip to content

fix creds scope for SAs during refresh #209

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func deletePullSecret(clientset *kubernetes.Clientset, ns corev1.Namespace) erro

// refreshAllPullSecrets deletes and recreates image registry pull secrets for all namespaces
func refreshAllPullSecrets() error {
creds, err := google.FindDefaultCredentials(context.Background())
creds, err := google.FindDefaultCredentials(context.Background(), "https://www.googleapis.com/auth/cloud-platform")

Choose a reason for hiding this comment

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

medium

While this change correctly adds the necessary scope, the scope URL "https://www.googleapis.com/auth/cloud-platform" is now duplicated (it also appears on line 82 in watchNamespaces).

To improve maintainability and avoid magic strings, please define this URL as a package-level constant and use it in both places.

For example, you could add the following at the top level of the file:

const gcpAuthScope = "https://www.googleapis.com/auth/cloud-platform"

And then use gcpAuthScope here.

if err != nil {
return fmt.Errorf("finding default credentials: %v", err)
}
Expand Down
Loading