You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(configure): replace az/gcloud CLI shell-outs with native SDK calls
Replace exec.Command shell-outs to cloud CLIs with native SDK calls where
the replacement is sound and does not require new heavyweight dependencies:
Azure (ci_cd_sanity_tests/):
- az account set/show -> armsubscriptions.Client.Get (programmatic CI path)
- az group list -> armresources.ResourceGroupsClient.NewListPager
- az vm list -> armcompute.VirtualMachinesClient.NewListAllPager
Azure (cmd/configure_azure.go):
- az account list -> armsubscriptions.Client.NewListPager (with CLI fallback)
GCP (cmd/configure_gcp.go):
- gcloud projects list -> cloudresourcemanager/v1 Projects.List
- gcloud iam service-accounts create -> iam/v1 Projects.ServiceAccounts.Create
- gcloud projects add-iam-policy-binding -> cloudresourcemanager/v1 SetIamPolicy
- gcloud iam service-accounts keys create -> iam/v1 SA Keys.Create (writes key
data to file; key is base64-decoded from PrivateKeyData response field)
Calls left as CLI (documented in each function):
- az login / gcloud auth login: interactive browser OAuth; no SDK equivalent
for an operator establishing an initial credential.
- gcloud config set project: writes to local gcloud config file; no API
equivalent.
- az ad sp create-for-rbac: would require msgraph-sdk-go +
armauthorization/v2, neither of which is in the module graph; the
interactive wizard path does not justify adding two new heavy SDKs.
Auth model: DefaultAzureCredential (azure.go / configure_azure.go) picks up
the az login session via its AzureCLICredential leg. google.DefaultTokenSource
(configure_gcp.go) picks up gcloud application-default credentials; the wizard
now notes that operators must also run 'gcloud auth application-default login'
in addition to 'gcloud auth login' for the SDK steps to work.
go.mod: armcompute/v5 and armsubscriptions promoted from indirect to direct;
armresources v1.2.0 promoted from transitive to direct. No new SDK versions
or packages outside the existing module graph were added (google.golang.org/api
iam/v1 and cloudresourcemanager/v1 are sub-packages of the already-required
google.golang.org/api v0.274.0).
Removes the gosec G204 subprocess findings from ci_cd_sanity_tests/azure.go
(the only nolint-free exec.Command site in the CI path). The remaining
exec.Command calls in configure_azure.go and configure_gcp.go are in
interactive wizard paths where the CLI is intentionally required; those are
addressed separately.
0 commit comments