Repository navigation
Closed
Labels
Description
What problem are you trying to solve?
kosli snapshot azure can only talk to the Azure public cloud. Its endpoints are fixed in
internal/azure/azure_apps.go:
getBearerTokenposts a hand-written client-credentials request to
https://login.microsoftonline.com/<tenant>/oauth2/tokenwith the resource
https://management.azure.com/;downloadAppPackagebuilds the Kudu URL ashttps://<app>.scm.azurewebsites.net/...;NewAzureClientpassesniloptions toazidentity.NewClientSecretCredentialand to
armappservice.NewClientFactory, so the SDK's public-cloud authority and Resource Manager
endpoint are used.
Two consequences:
- Cloud Capture cannot run the real CLI against a stand-in. Cloud Capture
(kosli-dev/cloud-capture#177) runs the built image through all three of its stages in its
end-to-end job against local stand-ins: moto for AWS, a fake Kosli API. The Searcher's own
Azure adapter takes its authority and Resource Manager URLs from the environment for that
reason, but the Snapshotter's last step is the CLI, and the CLI cannot be pointed anywhere but
Azure itself. The Azure path therefore stops one step short of the end inmake e2e, and is
covered only by unit tests on both sides. - Customers on a sovereign cloud cannot use the command. The ACR login-server check already
accepts.azurecr.cnand.azurecr.usregistries (acrLoginServerSuffixes), but a tenant in
Azure China or Azure Government authenticates against a different authority and a different
Resource Manager, so the command fails before it reaches the registry.
Proposed solution
Make the endpoints configurable in the way the SDK already supports, and remove the hand-written
token request so there is one place that knows the authority:
- A
--azure-cloudflag (valuespublic,china,usgov, defaultpublic) that selects
cloud.AzurePublic,cloud.AzureChinaorcloud.AzureGovernmentfrom
github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud, passed through
azidentity.ClientSecretCredentialOptions.ClientOptions.Cloudand
arm.ClientOptions.Cloudon the App Service client factory. - Overrides for the two hosts, for stand-ins and private clouds: flags or environment variables
along the lines ofKOSLI_AZURE_AUTHORITY_HOSTandKOSLI_AZURE_RESOURCE_MANAGER_URL, applied
as a customcloud.Configuration. azidentity already honoursAZURE_AUTHORITY_HOSTfrom the
environment when the cloud configuration leaves the authority empty, so the authority half may
only need documenting. - Replace
getBearerTokenwithGetTokenon the credential the client factory already holds,
asking for the Resource Manager audience from the chosen cloud configuration, so the Kudu
download uses the same authority as everything else. - Derive the Kudu host from the site's own
properties.hostNameSslStates(the entry with
hostTypeRepository) rather than the fixed.scm.azurewebsites.netsuffix, which differs
per cloud.
With that, Cloud Capture's end-to-end job would set the two overrides in the Snapshotter's
environment and point them at the stand-in that already serves the token endpoint and the site
list for the Searcher, and the Azure path would run end to end through the real CLI.
Alternatives considered
- Cloud Capture skips the CLI for Azure in its end-to-end job and asserts on the arguments the
Snapshotter would have passed. That loses exactly the coverage the job exists for. - An injectable HTTP transport for Go tests only (as
acrClientOptionsdoes for the ACR arm).
Useful inside the CLI's own tests (see Azure: add fake + contract tests, remove credential gate from CLI tests #812) but not reachable from another process, so it does
not help Cloud Capture or sovereign-cloud customers.
Activity