Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into ellismg/fix-509
Browse files Browse the repository at this point in the history
  • Loading branch information
ellismg committed Aug 15, 2024
2 parents 668fb38 + 83c5998 commit e6d6af7
Show file tree
Hide file tree
Showing 149 changed files with 911 additions and 1,305 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@
"jinliming2.vscode-go-template"
]
}
}
},
"postCreateCommand": "go install gotest.tools/gotestsum@latest"
}
3 changes: 2 additions & 1 deletion .devcontainer/light/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
"jinliming2.vscode-go-template"
]
}
}
},
"postCreateCommand": "go install gotest.tools/gotestsum@latest"
}
2 changes: 1 addition & 1 deletion .github/workflows/cli-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm install -g cspell
- run: npm install -g cspell@8.13.1
- name: Spell check for CLI source code
run: cspell lint '**/*.{go,md}' --config ./cli/azd/.vscode/cspell.yaml --root ./cli/azd --no-progress

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cspell-misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm install -g cspell
- run: npm install -g cspell@8.13.1
- name: Spell check for general files
run: cspell lint '**/*' --config ./.vscode/cspell.misc.yaml --relative --no-progress
2 changes: 1 addition & 1 deletion .github/workflows/templates-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm install -g cspell
- run: npm install -g cspell@8.13.1
- name: Spell check for templates
run: cspell lint '**/*' --config ./templates/cspell.yaml --root ./templates --no-progress
2 changes: 1 addition & 1 deletion .github/workflows/vscode-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: "20"
- run: npm install -g cspell
- run: npm install -g cspell@8.13.1
- name: Spell check for vscode extension
run: cspell lint '**/*.ts' --config ./ext/vscode/.vscode/cspell.yaml --root ./ext/vscode --no-progress

Expand Down
15 changes: 15 additions & 0 deletions cli/azd/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@

### Other Changes

## 1.9.6 (2024-08-13)

### Features Added

- [[4115]](https://github.com/Azure/azure-dev/pull/4115) Adding `alpha` feature `alpha.aca.persistIngressSessionAffinity`.

### Bugs Fixed

- [[4111]](https://github.com/Azure/azure-dev/pull/4111) Container Apps: Fail when explicit Dockerfile path not found.
- [[4149]](https://github.com/Azure/azure-dev/pull/4149) Remove Admin Access as default for all .Net Aspire services.
- [[4104]](https://github.com/Azure/azure-dev/pull/4104) Remove Azure Dev Ops git remote constraint for dev.azure.com only.
- [[4160]](https://github.com/Azure/azure-dev/pull/4160) Fix automatic generation of CI/CD files for .Net Aspire projects.
- [[4182]](https://github.com/Azure/azure-dev/pull/4182) Allow `.yaml` and `.yml` extension for azure-dev pipeline files.
- [[4187]](https://github.com/Azure/azure-dev/pull/4187) Fix panic during deployment progress rendering.

## 1.9.5 (2024-07-10)

### Features Added
Expand Down
9 changes: 4 additions & 5 deletions cli/azd/cmd/auth_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/MakeNowJust/heredoc/v2"
"github.com/azure/azure-dev/cli/azd/cmd/actions"
"github.com/azure/azure-dev/cli/azd/internal"
"github.com/azure/azure-dev/cli/azd/internal/runcontext"
"github.com/azure/azure-dev/cli/azd/pkg/account"
"github.com/azure/azure-dev/cli/azd/pkg/auth"
"github.com/azure/azure-dev/cli/azd/pkg/contracts"
Expand Down Expand Up @@ -257,8 +258,6 @@ func newLoginAction(
}
}

const cLoginSuccessMessage = "Logged in to Azure."

func (la *loginAction) Run(ctx context.Context) (*actions.ActionResult, error) {
if len(la.flags.scopes) == 0 {
la.flags.scopes = la.authManager.LoginScopes()
Expand Down Expand Up @@ -300,7 +299,7 @@ func (la *loginAction) Run(ctx context.Context) (*actions.ActionResult, error) {
var msg string
switch res.Status {
case contracts.LoginStatusSuccess:
msg = cLoginSuccessMessage
msg = "Logged in to Azure."
case contracts.LoginStatusUnauthenticated:
msg = "Not logged in, run `azd auth login` to login to Azure."
default:
Expand Down Expand Up @@ -331,7 +330,7 @@ func (la *loginAction) Run(ctx context.Context) (*actions.ActionResult, error) {
}
}

la.console.Message(ctx, cLoginSuccessMessage)
la.console.Message(ctx, "Logged in to Azure.")
return nil, nil
}

Expand Down Expand Up @@ -534,7 +533,7 @@ func parseUseDeviceCode(ctx context.Context, flag boolPtr, commandRunner exec.Co
useDevCode = runningOnCodespacesBrowser(ctx, commandRunner)
}

if auth.ShouldUseCloudShellAuth() {
if runcontext.IsRunningInCloudShell() {
// Following az CLI behavior in Cloud Shell, use device code authentication when the user is trying to
// authenticate. The normal interactive authentication flow will not work in Cloud Shell because the browser
// cannot be opened or (if it could) cannot be redirected back to a port on the Cloud Shell instance.
Expand Down
14 changes: 7 additions & 7 deletions cli/azd/cmd/auth_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/stretchr/testify/require"
)

const cManagementScope = "https://management.azure.com//.default"
const managementScope = "https://management.azure.com//.default"

func TestAuthToken(t *testing.T) {
wasCalled := false
Expand All @@ -34,7 +34,7 @@ func TestAuthToken(t *testing.T) {
wasCalled = true

// Default value when explicit scopes are not provided to the command.
require.ElementsMatch(t, []string{cManagementScope}, options.Scopes)
require.ElementsMatch(t, []string{managementScope}, options.Scopes)

return azcore.AccessToken{
Token: "ABC123",
Expand Down Expand Up @@ -70,7 +70,7 @@ func TestAuthTokenSysEnv(t *testing.T) {
buf := &bytes.Buffer{}

token := authTokenFn(func(ctx context.Context, options policy.TokenRequestOptions) (azcore.AccessToken, error) {
require.ElementsMatch(t, []string{cManagementScope}, options.Scopes)
require.ElementsMatch(t, []string{managementScope}, options.Scopes)
return azcore.AccessToken{
Token: "ABC123",
ExpiresOn: time.Unix(1669153000, 0).UTC(),
Expand Down Expand Up @@ -112,7 +112,7 @@ func TestAuthTokenSysEnvError(t *testing.T) {
buf := &bytes.Buffer{}

token := authTokenFn(func(ctx context.Context, options policy.TokenRequestOptions) (azcore.AccessToken, error) {
require.ElementsMatch(t, []string{cManagementScope}, options.Scopes)
require.ElementsMatch(t, []string{managementScope}, options.Scopes)
return azcore.AccessToken{
Token: "ABC123",
ExpiresOn: time.Unix(1669153000, 0).UTC(),
Expand Down Expand Up @@ -160,7 +160,7 @@ func TestAuthTokenAzdEnvError(t *testing.T) {
buf := &bytes.Buffer{}

token := authTokenFn(func(ctx context.Context, options policy.TokenRequestOptions) (azcore.AccessToken, error) {
require.ElementsMatch(t, []string{cManagementScope}, options.Scopes)
require.ElementsMatch(t, []string{managementScope}, options.Scopes)
return azcore.AccessToken{
Token: "ABC123",
ExpiresOn: time.Unix(1669153000, 0).UTC(),
Expand Down Expand Up @@ -204,7 +204,7 @@ func TestAuthTokenAzdEnv(t *testing.T) {
buf := &bytes.Buffer{}

token := authTokenFn(func(ctx context.Context, options policy.TokenRequestOptions) (azcore.AccessToken, error) {
require.ElementsMatch(t, []string{cManagementScope}, options.Scopes)
require.ElementsMatch(t, []string{managementScope}, options.Scopes)
return azcore.AccessToken{
Token: "ABC123",
ExpiresOn: time.Unix(1669153000, 0).UTC(),
Expand Down Expand Up @@ -245,7 +245,7 @@ func TestAuthTokenAzdEnvWithEmpty(t *testing.T) {
buf := &bytes.Buffer{}

token := authTokenFn(func(ctx context.Context, options policy.TokenRequestOptions) (azcore.AccessToken, error) {
require.ElementsMatch(t, []string{cManagementScope}, options.Scopes)
require.ElementsMatch(t, []string{managementScope}, options.Scopes)
return azcore.AccessToken{
Token: "ABC123",
ExpiresOn: time.Unix(1669153000, 0).UTC(),
Expand Down
6 changes: 2 additions & 4 deletions cli/azd/cmd/cobra_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import (
"github.com/spf13/cobra"
)

const cDocsFlagName = "docs"

// CobraBuilder manages the construction of the cobra command tree from nested ActionDescriptors
type CobraBuilder struct {
container *ioc.NestedContainer
Expand Down Expand Up @@ -196,7 +194,7 @@ func (df *docsFlag) Set(value string) error {
}

commandPath := strings.ReplaceAll(c.CommandPath(), " ", "-")
commandDocsUrl := cReferenceDocumentationUrl + commandPath
commandDocsUrl := referenceDocumentationUrl + commandPath
openWithDefaultBrowser(ctx, console, commandDocsUrl)
})

Expand All @@ -221,7 +219,7 @@ func (cb *CobraBuilder) bindCommand(cmd *cobra.Command, descriptor *actions.Acti
},
}
flag := cmd.Flags().VarPF(
docsFlag, cDocsFlagName, "", fmt.Sprintf("Opens the documentation for %s in your web browser.", cmd.CommandPath()))
docsFlag, "docs", "", fmt.Sprintf("Opens the documentation for %s in your web browser.", cmd.CommandPath()))
flag.NoOptDefVal = "true"

// Consistently registers output formats for the descriptor
Expand Down
2 changes: 1 addition & 1 deletion cli/azd/cmd/cobra_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func Test_RunDocsFlow(t *testing.T) {
cmd.SetArgs([]string{"--docs"})
err = cmd.ExecuteContext(*testCtx.Context)
require.NoError(t, err)
require.Equal(t, cReferenceDocumentationUrl+"root", calledUrl)
require.Equal(t, referenceDocumentationUrl+"root", calledUrl)
}

func Test_RunDocsAndHelpFlow(t *testing.T) {
Expand Down
76 changes: 29 additions & 47 deletions cli/azd/cmd/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
"github.com/MakeNowJust/heredoc/v2"
"github.com/azure/azure-dev/cli/azd/cmd/actions"
"github.com/azure/azure-dev/cli/azd/cmd/middleware"
Expand Down Expand Up @@ -143,11 +144,8 @@ func registerCommonDependencies(container *ioc.NestedContainer) {
)

client := createHttpClient()
ioc.RegisterInstance[httputil.HttpClient](container, client)
ioc.RegisterInstance[policy.Transporter](container, client)
ioc.RegisterInstance[auth.HttpClient](container, client)
container.MustRegisterSingleton(func() httputil.UserAgent {
return httputil.UserAgent(internal.UserAgent())
})

// Auth
container.MustRegisterSingleton(auth.NewLoggedInGuard)
Expand Down Expand Up @@ -468,32 +466,31 @@ func registerCommonDependencies(container *ioc.NestedContainer) {
return cloud.NewCloud(&cloud.Config{Name: cloud.AzurePublicName})
})

container.MustRegisterSingleton(func(cloud *cloud.Cloud) cloud.PortalUrlBase {
return cloud.PortalUrlBase
})

container.MustRegisterSingleton(func(
httpClient httputil.HttpClient,
userAgent httputil.UserAgent,
cloud *cloud.Cloud,
) *azsdk.ClientOptionsBuilderFactory {
return azsdk.NewClientOptionsBuilderFactory(httpClient, string(userAgent), cloud)
})

container.MustRegisterSingleton(func(
clientOptionsBuilderFactory *azsdk.ClientOptionsBuilderFactory,
) *azcore.ClientOptions {
return clientOptionsBuilderFactory.NewClientOptionsBuilder().
WithPerCallPolicy(azsdk.NewMsCorrelationPolicy()).
BuildCoreClientOptions()
container.MustRegisterSingleton(func(transport policy.Transporter, cloud *cloud.Cloud) *azcore.ClientOptions {
return &azcore.ClientOptions{
Cloud: cloud.Configuration,
PerCallPolicies: []policy.Policy{
azsdk.NewMsCorrelationPolicy(),
azsdk.NewUserAgentPolicy(internal.UserAgent()),
},
Transport: transport,
}
})

container.MustRegisterSingleton(func(
clientOptionsBuilderFactory *azsdk.ClientOptionsBuilderFactory,
) *arm.ClientOptions {
return clientOptionsBuilderFactory.NewClientOptionsBuilder().
WithPerCallPolicy(azsdk.NewMsCorrelationPolicy()).
BuildArmClientOptions()
container.MustRegisterSingleton(func(transport policy.Transporter, cloud *cloud.Cloud) *arm.ClientOptions {
return &arm.ClientOptions{
ClientOptions: azcore.ClientOptions{
Cloud: cloud.Configuration,
Logging: policy.LogOptions{
AllowedHeaders: []string{azsdk.MsCorrelationIdHeader},
},
PerCallPolicies: []policy.Policy{
azsdk.NewMsCorrelationPolicy(),
azsdk.NewUserAgentPolicy(internal.UserAgent()),
},
Transport: transport,
},
}
})

container.MustRegisterSingleton(templates.NewTemplateManager)
Expand Down Expand Up @@ -559,9 +556,9 @@ func registerCommonDependencies(container *ioc.NestedContainer) {
}
}
return auth.ExternalAuthConfiguration{
Endpoint: endpoint,
Client: client,
Key: key,
Endpoint: endpoint,
Transporter: client,
Key: key,
}, nil
})
container.MustRegisterScoped(auth.NewManager)
Expand All @@ -585,22 +582,7 @@ func registerCommonDependencies(container *ioc.NestedContainer) {
})

// Tools
container.MustRegisterSingleton(func(
rootOptions *internal.GlobalCommandOptions,
credentialProvider account.SubscriptionCredentialProvider,
httpClient httputil.HttpClient,
armClientOptions *arm.ClientOptions,
) azcli.AzCli {
return azcli.NewAzCli(
credentialProvider,
httpClient,
azcli.NewAzCliArgs{
EnableDebug: rootOptions.EnableDebugLogging,
EnableTelemetry: rootOptions.EnableTelemetry,
},
armClientOptions,
)
})
container.MustRegisterSingleton(azcli.NewAzCli)
container.MustRegisterSingleton(azapi.NewDeployments)
container.MustRegisterSingleton(azapi.NewDeploymentOperations)
container.MustRegisterSingleton(docker.NewCli)
Expand Down
4 changes: 2 additions & 2 deletions cli/azd/cmd/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func newMonitorAction(
deploymentOperations azapi.DeploymentOperations,
console input.Console,
flags *monitorFlags,
portalUrlBase cloud.PortalUrlBase,
cloud *cloud.Cloud,
alphaFeatureManager *alpha.FeatureManager,
) actions.Action {
return &monitorAction{
Expand All @@ -92,7 +92,7 @@ func newMonitorAction(
console: console,
flags: flags,
subResolver: subResolver,
portalUrlBase: string(portalUrlBase),
portalUrlBase: cloud.PortalUrlBase,
alphaFeaturesManager: alphaFeatureManager,
}
}
Expand Down
4 changes: 2 additions & 2 deletions cli/azd/cmd/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func newShowAction(
flags *showFlags,
lazyServiceManager *lazy.Lazy[project.ServiceManager],
lazyResourceManager *lazy.Lazy[project.ResourceManager],
portalUrlBase cloud.PortalUrlBase,
cloud *cloud.Cloud,
) actions.Action {
return &showAction{
projectConfig: projectConfig,
Expand All @@ -97,7 +97,7 @@ func newShowAction(
flags: flags,
lazyServiceManager: lazyServiceManager,
lazyResourceManager: lazyResourceManager,
portalUrlBase: string(portalUrlBase),
portalUrlBase: cloud.PortalUrlBase,
}
}

Expand Down
2 changes: 1 addition & 1 deletion cli/azd/cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,4 @@ func openWithDefaultBrowser(ctx context.Context, console input.Console, url stri
console.Message(ctx, fmt.Sprintf("Azd was unable to open the next url. Please try it manually: %s", url))
}

const cReferenceDocumentationUrl = "https://learn.microsoft.com/azure/developer/azure-developer-cli/reference#"
const referenceDocumentationUrl = "https://learn.microsoft.com/azure/developer/azure-developer-cli/reference#"
4 changes: 2 additions & 2 deletions cli/azd/internal/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func NewDeployAction(
azdCtx *azdcontext.AzdContext,
environment *environment.Environment,
accountManager account.Manager,
portalUrlBase cloud.PortalUrlBase,
cloud *cloud.Cloud,
azCli azcli.AzCli,
commandRunner exec.CommandRunner,
console input.Console,
Expand All @@ -152,7 +152,7 @@ func NewDeployAction(
serviceManager: serviceManager,
resourceManager: resourceManager,
accountManager: accountManager,
portalUrlBase: string(portalUrlBase),
portalUrlBase: cloud.PortalUrlBase,
azCli: azCli,
formatter: formatter,
writer: writer,
Expand Down
Loading

0 comments on commit e6d6af7

Please sign in to comment.