Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
wbreza committed Sep 25, 2024
1 parent 1cf55cc commit b575a03
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
5 changes: 3 additions & 2 deletions cli/azd/internal/cmd/provision.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"log"
"os"
"strconv"
"strings"
"time"

"github.com/azure/azure-dev/cli/azd/cmd/actions"
Expand Down Expand Up @@ -166,14 +167,14 @@ func (p *ProvisionAction) SetFlags(flags *ProvisionFlags) {
func (p *ProvisionAction) Run(ctx context.Context) (*actions.ActionResult, error) {
var targetServiceName string
if len(p.args) == 1 {
targetServiceName = p.args[0]
targetServiceName = strings.TrimSpace(p.args[0])
}

if targetServiceName != "" && p.flags.all {
return nil, fmt.Errorf("cannot specify both --all and <service>")
}

if targetServiceName == "" && p.flags.platform {
if targetServiceName != "" && p.flags.platform {
return nil, fmt.Errorf("cannot specify both --platform and <service>")
}

Expand Down
25 changes: 13 additions & 12 deletions cli/azd/internal/cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"context"
"errors"
"fmt"
"os"
"strconv"
"time"

"github.com/azure/azure-dev/cli/azd/internal/tracing"
Expand Down Expand Up @@ -34,19 +32,22 @@ func getResourceGroupFollowUp(
projectConfig.ResourceGroupName,
)
if err == nil {
suffix := ":\n" + azurePortalLink(portalUrlBase, subscriptionId, resourceGroupName)

if v, err := strconv.ParseBool(os.Getenv("AZD_DEMO_MODE")); err == nil && v {
suffix = "."
}
resourceGroupLink := azurePortalLink(portalUrlBase, subscriptionId, resourceGroupName)
azurePortalHyperlink := output.WithHyperlink(resourceGroupLink, "Azure Portal")

defaultFollowUpText := fmt.Sprintf(
"You can view the resources created under the resource group %s in Azure Portal", resourceGroupName)
"You can view the resources created under the resource group %s in the %s",
output.WithHighLightFormat(resourceGroupName),
azurePortalHyperlink,
)
if whatIf {
defaultFollowUpText = fmt.Sprintf(
"You can view the current resources under the resource group %s in Azure Portal", resourceGroupName)
"You can view the current resources under the resource group %s in the %s",
output.WithHighLightFormat(resourceGroupName),
azurePortalHyperlink,
)
}
followUp = defaultFollowUpText + suffix
followUp = defaultFollowUpText
}

return followUp
Expand All @@ -56,11 +57,11 @@ func azurePortalLink(portalUrlBase, subscriptionId, resourceGroupName string) st
if subscriptionId == "" || resourceGroupName == "" {
return ""
}
return output.WithLinkFormat(fmt.Sprintf(
return fmt.Sprintf(
"%s/#@/resource/subscriptions/%s/resourceGroups/%s/overview",
portalUrlBase,
subscriptionId,
resourceGroupName))
resourceGroupName)
}

func getTargetServiceName(
Expand Down
15 changes: 7 additions & 8 deletions cli/azd/pkg/output/ux/environment_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ package ux
import (
"encoding/json"
"fmt"
"strings"

"github.com/azure/azure-dev/cli/azd/pkg/output"
"github.com/fatih/color"
)

type EnvironmentDetails struct {
Expand All @@ -17,15 +17,14 @@ type EnvironmentDetails struct {
}

func (t *EnvironmentDetails) ToString(currentIndentation string) string {
var location string
lines := []string{}
if t.Location != "" {
location = fmt.Sprintf("\nLocation: %s", color.BlueString(t.Location))
lines = append(lines, fmt.Sprintf("Location: %s", output.WithHighLightFormat(t.Location)))
}
return fmt.Sprintf(
"Subscription: %s%s\n",
color.BlueString(t.Subscription),
location,
)

lines = append(lines, fmt.Sprintf("Subscription: %s", output.WithHighLightFormat(t.Subscription)))

return strings.Join(lines, "\n") + "\n"
}

func (t *EnvironmentDetails) MarshalJSON() ([]byte, error) {
Expand Down

0 comments on commit b575a03

Please sign in to comment.