Skip to content

Commit

Permalink
Merge branch 'main' into feature/update-spring-boot-properties-file-f…
Browse files Browse the repository at this point in the history
…or-postgresql
  • Loading branch information
rujche authored Jan 24, 2025
2 parents a3f83b7 + e5f983a commit 65d37fd
Show file tree
Hide file tree
Showing 34 changed files with 2,923 additions and 6,597 deletions.
16 changes: 8 additions & 8 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-syntax

/** @ellismg @wbreza
/** @wbreza

/cli/ @ellismg @wbreza @vhvb1989 @hemarina @weikanglim @JeffreyCA
/cli/installer/ @ellismg @danieljurek
/cli/ @wbreza @vhvb1989 @hemarina @weikanglim @JeffreyCA
/cli/installer/ @danieljurek

/ext/ @karolz-ms @ellismg
/ext/ @karolz-ms

/generators/repo/ @wbreza @ellismg @danieljurek
/generators/repo/ @wbreza @danieljurek

/.github/ @danieljurek @ellismg
/.github/ @danieljurek

/.config/1espt/ @danieljurek @benbp @weshaggard

/eng/ @danieljurek @ellismg
/eng/ @danieljurek

/schemas/ @karolz-ms @ellismg @wbreza
/schemas/ @karolz-ms @wbreza

/templates/ @jongio @wbreza

Expand Down
34 changes: 30 additions & 4 deletions cli/azd/cmd/auth_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/azure/azure-dev/cli/azd/pkg/input"
"github.com/azure/azure-dev/cli/azd/pkg/oneauth"
"github.com/azure/azure-dev/cli/azd/pkg/output"
"github.com/azure/azure-dev/cli/azd/pkg/output/ux"
"github.com/azure/azure-dev/cli/azd/pkg/tools/github"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
Expand Down Expand Up @@ -318,14 +319,28 @@ func (la *loginAction) Run(ctx context.Context) (*actions.ActionResult, error) {
var msg string
switch res.Status {
case contracts.LoginStatusSuccess:
msg = "Logged in to Azure."
msg = "Logged in to Azure"
case contracts.LoginStatusUnauthenticated:
msg = "Not logged in, run `azd auth login` to login to Azure."
msg = "Not logged in, run `azd auth login` to login to Azure"
default:
panic("Unhandled login status")
}

fmt.Fprintln(la.console.Handles().Stdout, msg)
// get user account information - login --check-status
details, err := la.authManager.LogInDetails(ctx)

// error getting user account or not logged in
if err != nil {
log.Printf("error: getting signed in account: %v", err)
fmt.Fprintln(la.console.Handles().Stdout, msg)
return nil, nil
}

// only print the message if the user is logged in
la.console.MessageUxItem(ctx, &ux.LoggedIn{
LoggedInAs: details.Account,
LoginType: ux.LoginType(details.LoginType),
})
return nil, nil
}
}
Expand Down Expand Up @@ -354,7 +369,18 @@ func (la *loginAction) Run(ctx context.Context) (*actions.ActionResult, error) {
}
}

la.console.Message(ctx, "Logged in to Azure.")
details, err := la.authManager.LogInDetails(ctx)

// error getting user account, successful log in
if err != nil {
log.Printf("error: getting signed in account: %v", err)
la.console.Message(ctx, "Logged in to Azure")
return nil, nil
}
la.console.MessageUxItem(ctx, &ux.LoggedIn{
LoggedInAs: details.Account,
LoginType: ux.LoginType(details.LoginType),
})
return nil, nil
}

Expand Down
8 changes: 2 additions & 6 deletions cli/azd/internal/cmd/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

"github.com/Azure/azure-sdk-for-go/sdk/azcore/arm"
"github.com/azure/azure-dev/cli/azd/cmd/actions"
"github.com/azure/azure-dev/cli/azd/internal/repository"
"github.com/azure/azure-dev/cli/azd/pkg/account"
"github.com/azure/azure-dev/cli/azd/pkg/alpha"
"github.com/azure/azure-dev/cli/azd/pkg/environment"
Expand Down Expand Up @@ -50,7 +49,6 @@ type AddAction struct {
alphaManager *alpha.FeatureManager
creds account.SubscriptionCredentialProvider
rm infra.ResourceManager
appInit *repository.Initializer
armClientOptions *arm.ClientOptions
prompter prompt.Prompter
console input.Console
Expand Down Expand Up @@ -93,7 +91,7 @@ func (a *AddAction) Run(ctx context.Context) (*actions.ActionResult, error) {
resourceToAdd := &project.ResourceConfig{}
var serviceToAdd *project.ServiceConfig

promptOpts := promptOptions{prj: prjConfig}
promptOpts := PromptOptions{PrjConfig: prjConfig}
if strings.EqualFold(selected.Namespace, "host") {
svc, r, err := a.configureHost(a.console, ctx, promptOpts)
if err != nil {
Expand All @@ -111,7 +109,7 @@ func (a *AddAction) Run(ctx context.Context) (*actions.ActionResult, error) {
resourceToAdd = r
}

resourceToAdd, err = configure(ctx, resourceToAdd, a.console, promptOpts)
resourceToAdd, err = Configure(ctx, resourceToAdd, a.console, promptOpts)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -368,7 +366,6 @@ func NewAddAction(
prompter prompt.Prompter,
rm infra.ResourceManager,
armClientOptions *arm.ClientOptions,
appInit *repository.Initializer,
azd workflow.AzdCommandRunner,
console input.Console) actions.Action {
return &AddAction{
Expand All @@ -381,7 +378,6 @@ func NewAddAction(
prompter: prompter,
rm: rm,
armClientOptions: armClientOptions,
appInit: appInit,
creds: creds,
azd: azd,
}
Expand Down
44 changes: 26 additions & 18 deletions cli/azd/internal/cmd/add/add_configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,32 @@ import (
"strings"
"unicode"

"github.com/azure/azure-dev/cli/azd/internal/appdetect"
"github.com/azure/azure-dev/cli/azd/pkg/input"
"github.com/azure/azure-dev/cli/azd/pkg/output"
"github.com/azure/azure-dev/cli/azd/pkg/project"
"github.com/fatih/color"
)

// promptOptions contains common options for prompting.
type promptOptions struct {
// prj is the current project configuration.
prj *project.ProjectConfig
// DbMap is a map of supported database dependencies.
var DbMap = map[appdetect.DatabaseDep]project.ResourceType{
appdetect.DbMongo: project.ResourceTypeDbMongo,
appdetect.DbPostgres: project.ResourceTypeDbPostgres,
appdetect.DbRedis: project.ResourceTypeDbRedis,
}

// configure fills in the fields for a resource.
func configure(
// PromptOptions contains common options for prompting.
type PromptOptions struct {
// PrjConfig is the current project configuration.
PrjConfig *project.ProjectConfig
}

// Configure fills in the fields for a resource.
func Configure(
ctx context.Context,
r *project.ResourceConfig,
console input.Console,
p promptOptions) (*project.ResourceConfig, error) {
p PromptOptions) (*project.ResourceConfig, error) {
switch r.Type {
case project.ResourceTypeHostContainerApp:
return fillUses(ctx, r, console, p)
Expand All @@ -34,7 +42,7 @@ func configure(
project.ResourceTypeDbMongo:
return fillDatabaseName(ctx, r, console, p)
case project.ResourceTypeDbRedis:
if _, exists := p.prj.Resources["redis"]; exists {
if _, exists := p.PrjConfig.Resources["redis"]; exists {
return nil, fmt.Errorf("only one Redis resource is allowed at this time")
}

Expand All @@ -49,7 +57,7 @@ func fillDatabaseName(
ctx context.Context,
r *project.ResourceConfig,
console input.Console,
p promptOptions) (*project.ResourceConfig, error) {
p PromptOptions) (*project.ResourceConfig, error) {
if r.Name != "" {
return r, nil
}
Expand All @@ -65,7 +73,7 @@ func fillDatabaseName(
return r, err
}

if err := validateResourceName(dbName, p.prj); err != nil {
if err := validateResourceName(dbName, p.PrjConfig); err != nil {
console.Message(ctx, err.Error())
continue
}
Expand All @@ -81,7 +89,7 @@ func fillAiModelName(
ctx context.Context,
r *project.ResourceConfig,
console input.Console,
p promptOptions) (*project.ResourceConfig, error) {
p PromptOptions) (*project.ResourceConfig, error) {
if r.Name != "" {
return r, nil
}
Expand All @@ -94,7 +102,7 @@ func fillAiModelName(
defaultName = modelProps.Model.Name
i := 1
for {
if _, exists := p.prj.Resources[defaultName]; exists {
if _, exists := p.PrjConfig.Resources[defaultName]; exists {
i++
defaultName = fmt.Sprintf("%s-%d", defaultName, i)
} else {
Expand All @@ -112,7 +120,7 @@ func fillAiModelName(
return nil, err
}

if err := validateResourceName(modelName, p.prj); err != nil {
if err := validateResourceName(modelName, p.PrjConfig); err != nil {
console.Message(ctx, err.Error())
continue
}
Expand All @@ -128,13 +136,13 @@ func fillUses(
ctx context.Context,
r *project.ResourceConfig,
console input.Console,
p promptOptions) (*project.ResourceConfig, error) {
p PromptOptions) (*project.ResourceConfig, error) {
type resourceDisplay struct {
Resource *project.ResourceConfig
Display string
}
res := make([]resourceDisplay, 0, len(p.prj.Resources))
for _, r := range p.prj.Resources {
res := make([]resourceDisplay, 0, len(p.PrjConfig.Resources))
for _, r := range p.PrjConfig.Resources {
res = append(res, resourceDisplay{
Resource: r,
Display: fmt.Sprintf(
Expand Down Expand Up @@ -190,9 +198,9 @@ func promptUsedBy(
ctx context.Context,
r *project.ResourceConfig,
console input.Console,
p promptOptions) ([]string, error) {
p PromptOptions) ([]string, error) {
svc := []string{}
for _, other := range p.prj.Resources {
for _, other := range p.PrjConfig.Resources {
if strings.HasPrefix(string(other.Type), "host.") && !slices.Contains(r.Uses, other.Name) {
svc = append(svc, other.Name)
}
Expand Down
Loading

0 comments on commit 65d37fd

Please sign in to comment.