-
Notifications
You must be signed in to change notification settings - Fork 1
Fix: credentials file path resolution in generate-kubeconfig #6
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: credentials file path resolution in generate-kubeconfig #6
Conversation
WalkthroughThis change removes explicit HOME initialization from the Makefile and reworks kubeconfig generation to resolve provider credentials (GCP, AWS, Azure) from flags or environment variables, validate them, and propagate a provider-specific Sequence Diagram(s)sequenceDiagram
participant User as User/CLI
participant Gen as Kubeconfig Generator
participant FS as Filesystem (creds file)
participant Kubeconfig as kubeconfig
participant Exec as hyperfleet-credential-provider
participant Cloud as Cloud Auth API
User->>Gen: run kubeconfig command (flags/env)
Gen->>FS: resolve creds path (flag -> env per-provider)
Gen-->>Gen: set providerInfo.creds-path & creds-env
Gen->>Kubeconfig: write kubeconfig with execConfig (command,args,env)
User->>kubectl: run kubectl using kubeconfig
kubectl->>Exec: exec credential-provider (execConfig.cmd + env)
Exec->>FS: read creds file (from creds-env)
Exec->>Cloud: request token using credentials
Cloud-->>Exec: return token
Exec-->>kubectl: return client-token
kubectl->>KubernetesAPI: authenticate with token
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@cmd/provider/kubeconfig/generate.go`:
- Around line 162-170: The error string returned when GCP credentials are
missing (constructed with fmt.Errorf using credsPath/flags.CredentialsFile)
starts with a capital letter; update that fmt.Errorf message to begin with a
lowercase letter and do the same for the two other error returns in the same
file (the other fmt.Errorf usages flagged in the review) so all error messages
follow Go's ST1005 convention; locate the error strings constructed in
generate.go (references: credsPath, flags.CredentialsFile, and the three
fmt.Errorf calls reported) and change their leading characters to lowercase
while preserving the rest of the message content.
- Around line 209-225: The code currently reads AWS_CREDENTIALS_FILE; change the
lookup logic so credsPath is set by priority: flags.CredentialsFile, then
os.Getenv("AWS_SHARED_CREDENTIALS_FILE"), then
os.Getenv("AWS_CREDENTIALS_FILE"); update the providerInfo map entry "creds-env"
to reflect the actual env var used ("AWS_SHARED_CREDENTIALS_FILE" or
"AWS_CREDENTIALS_FILE") (keep "creds-path" as credsPath) so the kubeconfig
exports the standard AWS_SHARED_CREDENTIALS_FILE when appropriate.
fbb1fef to
7d2d279
Compare
yingzhanredhat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: yingzhanredhat The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
dc3c299
into
openshift-hyperfleet:main
Summary by CodeRabbit
New Features
Improvements