Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cli/azd/.vscode/cspell-azd-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ godotenv
golangci
ldflags
mgmt
mgutz
nodeapp
nolint
omitempty
Expand Down
14 changes: 9 additions & 5 deletions cli/azd/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
"github.com/azure/azure-dev/cli/azd/pkg/project"
"github.com/azure/azure-dev/cli/azd/pkg/spin"
"github.com/azure/azure-dev/cli/azd/pkg/tools"
"github.com/fatih/color"
"github.com/mattn/go-colorable"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/theckman/yacspin"
Expand Down Expand Up @@ -190,8 +188,14 @@ func (d *deployAction) Run(ctx context.Context, cmd *cobra.Command, args []strin
}

for _, resourceGroup := range resourceGroups {
resourcesGroupsURL := color.HiBlueString("https://portal.azure.com/#@/resource/subscriptions/%s/resourceGroups/%s/overview", env.GetSubscriptionId(), resourceGroup)
fmt.Fprintf(colorable.NewColorableStdout(), "View the resources created under the resource group %s in Azure Portal:\n%s", color.CyanString(resourceGroup), resourcesGroupsURL)
resourcesGroupsURL := withLinkFormat(
"https://portal.azure.com/#@/resource/subscriptions/%s/resourceGroups/%s/overview",
env.GetSubscriptionId(),
resourceGroup)
printWithStyling(
"View the resources created under the resource group %s in Azure Portal:\n%s",
withHighLightFormat(resourceGroup),
resourcesGroupsURL)
}

return nil
Expand All @@ -201,7 +205,7 @@ func reportServiceDeploymentResultInteractive(s *yacspin.Spinner, svc *project.S
var builder strings.Builder

for _, endpoint := range sdr.Endpoints {
builder.WriteString(fmt.Sprintf(" - Endpoint: %s\n", color.HiBlueString(endpoint)))
builder.WriteString(fmt.Sprintf(" - Endpoint: %s\n", withLinkFormat(endpoint)))
}

stopMessage := fmt.Sprintf("\nDeployed service %s\n%s", svc.Config.Name, builder.String())
Expand Down
11 changes: 7 additions & 4 deletions cli/azd/cmd/infra_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
"github.com/azure/azure-dev/cli/azd/pkg/spin"
"github.com/azure/azure-dev/cli/azd/pkg/tools"
"github.com/drone/envsubst"
"github.com/fatih/color"
"github.com/mattn/go-colorable"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/theckman/yacspin"
Expand Down Expand Up @@ -229,8 +227,13 @@ func (ica *infraCreateAction) Run(ctx context.Context, cmd *cobra.Command, args

if interactive {
deploymentSlug := azure.SubscriptionDeploymentRID(env.GetSubscriptionId(), env.GetEnvName())
deploymentURL := color.HiBlueString("https://portal.azure.com/#blade/HubsExtension/DeploymentDetailsBlade/overview/id/%s\n\n", url.PathEscape(deploymentSlug))
fmt.Fprintf(colorable.NewColorableStdout(), "Provisioning Azure resources can take some time.\n\nYou can view detailed progress in the Azure Portal:\n%s", deploymentURL)
deploymentURL := withLinkFormat(
"https://portal.azure.com/#blade/HubsExtension/DeploymentDetailsBlade/overview/id/%s\n\n",
url.PathEscape(deploymentSlug))
printWithStyling(
"Provisioning Azure resources can take some time.\n\nYou can view detailed progress in the Azure Portal:\n%s",
deploymentURL)
//fmt.Fprintf(colorable.NewColorableStdout(), "Provisioning Azure resources can take some time.\n\nYou can view detailed progress in the Azure Portal:\n%s", deploymentURL)

err = spin.RunWithUpdater("Creating Azure resources ", deployAndReportProgress,
func(s *yacspin.Spinner, deploySuccess bool) {
Expand Down
21 changes: 21 additions & 0 deletions cli/azd/cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import (
"github.com/azure/azure-dev/cli/azd/pkg/environment"
"github.com/azure/azure-dev/cli/azd/pkg/templates"
"github.com/azure/azure-dev/cli/azd/pkg/tools"
"github.com/fatih/color"
"github.com/mattn/go-isatty"
"github.com/mgutz/ansi"
)

type Asker func(p survey.Prompt, response interface{}) error
Expand Down Expand Up @@ -550,3 +552,22 @@ func ensureProject(path string) error {

return nil
}

// withLinkFormat creates string with hyperlink-looking color
func withLinkFormat(link string, a ...interface{}) string {
// See ansi colors: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
// ansi code `30` is the one that matches the survey selection
return ansi.Color(fmt.Sprintf(link, a...), "30")
}

// withHighLightFormat creates string with highlight-looking color
func withHighLightFormat(text string, a ...interface{}) string {
return color.CyanString(text, a...)
}

// printWithStyling prints text to stdout and handles Windows terminals to support
// escape chars from the text for adding style (color, font, etc)
func printWithStyling(text string, a ...interface{}) {
colorTerminal := color.New()
colorTerminal.Printf(text, a...)
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ require (
github.com/fatih/color v1.13.0
github.com/joho/godotenv v1.4.0
github.com/magefile/mage v1.12.1
github.com/mattn/go-colorable v0.1.12
github.com/mattn/go-isatty v0.0.14
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b
github.com/otiai10/copy v1.7.0
github.com/pbnj/go-open v0.1.1
github.com/sethvargo/go-retry v0.2.3
Expand All @@ -28,8 +28,8 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
Expand Down