Refactor: use az account show for tenant ID and subscription ID; move kubeconfig/k8s helpers to shared packages#55
Conversation
…ions to shared packages Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
az account show for tenant ID; move kubeconfig/k8s helpers to shared packages
plugin/pkg/util/config/config.go
Outdated
There was a problem hiding this comment.
@copilot do a similar update to extract sub id from az cli output for this function
There was a problem hiding this comment.
Done in 7fee6b5. defaultSubscriptionID() now uses az account show --query 'id' -o tsv, dropping the clouds.config / ini dependency.
plugin/pkg/util/k8s/k8s.go
Outdated
| // APIServerFromKubeconfigFile returns the API server hostname and port from | ||
| // the current context of the kubeconfig file at path. | ||
| func APIServerFromKubeconfigFile(path string) (host, port string, err error) { | ||
| kcfg, err := clientcmd.LoadFromFile(path) |
There was a problem hiding this comment.
Fixed in 7fee6b5. The function body was appended without tabs — restored proper Go indentation.
…onfigFile Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
az account show for tenant ID; move kubeconfig/k8s helpers to shared packagesaz account show for tenant ID and subscription ID; move kubeconfig/k8s helpers to shared packages
plugin/pkg/util/k8s/k8s.go
Outdated
|
|
||
| // APIServerFromKubeconfigFile returns the API server hostname and port from | ||
| // the current context of the kubeconfig file at path. | ||
| func APIServerFromKubeconfigFile(path string) (host, port string, err error) { |
There was a problem hiding this comment.
@copilot add support for passing the context name to load
There was a problem hiding this comment.
Done in 1f10452. APIServerFromKubeconfigFile now takes a contextName string — when non-empty it uses that context directly; when empty it falls back to the file's current-context.
cli/internal/aks/deploy/cilium.go
Outdated
| cfg *config.Config, | ||
| ) error { | ||
| k8sServiceHost, k8sServicePort, err := kubeconfigAPIServer(kubeconfigFile) | ||
| k8sServiceHost, k8sServicePort, err := k8s.APIServerFromKubeconfigFile(kubeconfigFile) |
There was a problem hiding this comment.
@copilot pass in the context name to load to match with the --context used in the below
There was a problem hiding this comment.
Done in 1f10452. Now passes cfg.ClusterName+"-admin" as the context name, matching the --context flag used by cilium install.
…t in cilium deploy Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
cli/internal/aks/deploy/cilium.go
Outdated
| cfg *config.Config, | ||
| ) error { | ||
| k8sServiceHost, k8sServicePort, err := kubeconfigAPIServer(kubeconfigFile) | ||
| k8sServiceHost, k8sServicePort, err := k8s.APIServerFromKubeconfigFile(kubeconfigFile, cfg.ClusterName+"-admin") |
There was a problem hiding this comment.
extract cfg.ClusterName + "-admin" as a variable then reuse with the later helm cmd parameters reference @copilot
There was a problem hiding this comment.
Done in 217c0c3. Extracted clusterContext := cfg.ClusterName + "-admin" and reused it in APIServerFromKubeconfigFile, the --context flag, and log.Printf.
…ver lookup and cilium install flags Co-authored-by: bcho <1975118+bcho@users.noreply.github.com>
* fix node bootstrap script for held kube packages * fix Azure profile-aware AKS Flex bootstrap * Refactor: use `az account show` for tenant ID and subscription ID; move kubeconfig/k8s helpers to shared packages (#55) * Initial plan * Address review feedback: use az CLI for tenant ID, move utility functions to shared packages Co-authored-by: bcho <1975118+bcho@users.noreply.github.com> * Use az CLI for subscription ID; fix indentation in APIServerFromKubeconfigFile Co-authored-by: bcho <1975118+bcho@users.noreply.github.com> * Add contextName parameter to APIServerFromKubeconfigFile; pass context in cilium deploy Co-authored-by: bcho <1975118+bcho@users.noreply.github.com> * Extract clusterContext variable in deployCilium; reuse across API server lookup and cilium install flags Co-authored-by: bcho <1975118+bcho@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bcho <1975118+bcho@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Run go mod tidy across all submodules (#56) * Initial plan * Run go mod tidy across all submodules (cli, karpenter, plugin) Co-authored-by: bcho <1975118+bcho@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bcho <1975118+bcho@users.noreply.github.com> --------- Co-authored-by: Qi Ke <noreply@ked.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: bcho <1975118+bcho@users.noreply.github.com> Co-authored-by: hbc <bahe@microsoft.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
defaultSubscriptionID()to useaz account show --query 'id' -o tsvAPIServerFromKubeconfigFilecontextName stringparameter toAPIServerFromKubeconfigFile(empty = use current-context)cilium.goto passcfg.ClusterName+"-admin"context name matching the--contextflagcfg.ClusterName+"-admin"asclusterContextvariable; reuse inAPIServerFromKubeconfigFile,--context, andlog.Printf🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.