This commit is contained in:
Matt Ellis 2024-08-26 14:00:58 -07:00 коммит произвёл GitHub
Родитель 19b04591de
Коммит 1c0cb36b2b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
51 изменённых файлов: 156 добавлений и 150 удалений

Просмотреть файл

@ -3,9 +3,11 @@
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/devcontainers/features/go:1": {
"version": "1.21"
"version": "1.23"
},
"ghcr.io/guiyomh/features/golangci-lint:0":{
"version": "1.60.1"
},
"ghcr.io/guiyomh/features/golangci-lint:0":{},
"ghcr.io/devcontainers/features/docker-in-docker:2.11.0": {
"version": "latest",
"moby": true

Просмотреть файл

@ -3,9 +3,11 @@
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/devcontainers/features/go:1": {
"version": "1.21"
"version": "1.23"
},
"ghcr.io/guiyomh/features/golangci-lint:0":{
"version": "1.60.1"
},
"ghcr.io/guiyomh/features/golangci-lint:0":{},
"ghcr.io/devcontainers/features/docker-in-docker:2.11.0": {
"version": "latest",
"moby": true

4
.github/workflows/cli-ci.yml поставляемый
Просмотреть файл

@ -21,12 +21,12 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: "^1.21.0"
go-version: "^1.23.0"
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54.1
version: v1.60.1
args: -v --timeout 10m0s
working-directory: cli/azd

Просмотреть файл

@ -140,7 +140,7 @@ func TestAuthTokenSysEnvError(t *testing.T) {
return nil, fmt.Errorf("not an azd env directory")
},
&mockSubscriptionTenantResolver{
Err: fmt.Errorf(expectedError),
Err: errors.New(expectedError),
},
cloud.AzurePublic(),
)
@ -184,7 +184,7 @@ func TestAuthTokenAzdEnvError(t *testing.T) {
}), nil
},
&mockSubscriptionTenantResolver{
Err: fmt.Errorf(expectedError),
Err: errors.New(expectedError),
},
cloud.AzurePublic(),
)

Просмотреть файл

@ -82,7 +82,7 @@ func getCmdHelpDefaultDescription(cmd *cobra.Command) string {
// getCmdHelpDefaultUsage provides the default implementation for displaying the help usage section.
func getCmdHelpDefaultUsage(cmd *cobra.Command) string {
return fmt.Sprintf("%s\n %s\n\n",
output.WithBold(output.WithUnderline("Usage")),
output.WithBold("%s", output.WithUnderline("Usage")),
"{{if .Runnable}}{{.UseLine}}{{end}}{{if .HasAvailableSubCommands}}{{.CommandPath}} [command]{{end}}",
)
}
@ -97,13 +97,13 @@ func getCmdHelpDefaultFlags(cmd *cobra.Command) (result string) {
if cmd.HasAvailableLocalFlags() {
flags := getFlagsDetails(cmd.LocalFlags())
result = fmt.Sprintf("%s\n%s\n",
output.WithBold(output.WithUnderline("Flags")),
output.WithBold("%s", output.WithUnderline("Flags")),
flags)
}
if cmd.HasAvailableInheritedFlags() {
globalFlags := getFlagsDetails(cmd.InheritedFlags())
result += fmt.Sprintf("%s\n%s\n",
output.WithBold(output.WithUnderline("Global Flags")),
output.WithBold("%s", output.WithUnderline("Global Flags")),
globalFlags)
}
return result
@ -128,7 +128,7 @@ func getCmdHelpCommands(title string, commands string) string {
if commands == "" {
return commands
}
return fmt.Sprintf("%s\n%s\n", output.WithBold(output.WithUnderline(title)), commands)
return fmt.Sprintf("%s\n%s\n", output.WithBold("%s", output.WithUnderline("%s", title)), commands)
}
// getCmdHelpGroupedCommands generates {{ commands - description }} where sub-commands are grouped.
@ -280,7 +280,7 @@ func generateCmdHelpSamplesBlock(samples map[string]string) string {
// sorting lines to keep a deterministic output, as map[string]string is not ordered
slices.Sort(lines)
return fmt.Sprintf("%s\n%s\n",
output.WithBold(output.WithUnderline("Examples")),
output.WithBold("%s", output.WithUnderline("Examples")),
strings.Join(lines, "\n\n"),
)
}

Просмотреть файл

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"maps"
"path/filepath"
"runtime"
"slices"
@ -18,7 +19,6 @@ import (
"github.com/azure/azure-dev/cli/azd/pkg/output"
"github.com/azure/azure-dev/cli/azd/pkg/output/ux"
"github.com/spf13/cobra"
"golang.org/x/exp/maps"
)
var userConfigPath string
@ -457,9 +457,7 @@ func (a *configListAlphaAction) Run(ctx context.Context) (*actions.ActionResult,
return nil, err
}
featureKeys := maps.Keys(features)
slices.Sort(featureKeys)
featureKeys := slices.Sorted(maps.Keys(features))
var alphaOutput []string
for _, alphaFeatureKey := range featureKeys {
alphaFeature := features[alphaFeatureKey]

Просмотреть файл

@ -8,6 +8,7 @@ import (
"net/http"
"net/url"
"os"
"slices"
"strings"
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
@ -67,7 +68,6 @@ import (
"github.com/azure/azure-dev/cli/azd/pkg/workflow"
"github.com/mattn/go-colorable"
"github.com/spf13/cobra"
"golang.org/x/exp/slices"
)
// Registers a transient action initializer for the specified action name

Просмотреть файл

@ -84,7 +84,7 @@ func (a *infraSynthAction) Run(ctx context.Context) (*actions.ActionResult, erro
if !a.alphaManager.IsEnabled(infraSynthFeature) {
return nil, fmt.Errorf(
"infrastructure synthesis is currently under alpha support and must be explicitly enabled."+
" Run `%s` to enable this feature.", alpha.GetEnableCommand(infraSynthFeature),
" Run `%s` to enable this feature", alpha.GetEnableCommand(infraSynthFeature),
)
}

Просмотреть файл

@ -146,7 +146,7 @@ func (i *initAction) Run(ctx context.Context) (*actions.ActionResult, error) {
if i.flags.templateBranch != "" && i.flags.templatePath == "" {
return nil,
errors.New(
"Using branch argument (-b or --branch) requires a template argument (--template or -t) to be specified.")
"using branch argument (-b or --branch) requires a template argument (--template or -t) to be specified")
}
// ensure that git is available

Просмотреть файл

@ -74,7 +74,7 @@ func (m *HooksMiddleware) registerCommandHooks(
projectConfig *project.ProjectConfig,
next NextFn,
) (*actions.ActionResult, error) {
if projectConfig.Hooks == nil || len(projectConfig.Hooks) == 0 {
if len(projectConfig.Hooks) == 0 {
log.Println(
"azd project is not available or does not contain any command hooks, skipping command hook registrations.",
)
@ -139,7 +139,7 @@ func (m *HooksMiddleware) registerServiceHooks(
for _, service := range stableServices {
serviceName := service.Name
// If the service hasn't configured any hooks we can continue on.
if service.Hooks == nil || len(service.Hooks) == 0 {
if len(service.Hooks) == 0 {
log.Printf("service '%s' does not require any command hooks.\n", serviceName)
continue
}

Просмотреть файл

@ -379,7 +379,7 @@ func NewRootCmd(
func getCmdRootHelpFooter(cmd *cobra.Command) string {
return fmt.Sprintf("%s\n%s\n%s\n\n%s\n\n%s",
output.WithBold(output.WithUnderline("Deploying a sample application")),
output.WithBold("%s", output.WithUnderline("Deploying a sample application")),
"Initialize from a sample application by running the "+
output.WithHighLightFormat("azd init --template ")+
output.WithWarningFormat("[%s]", "template name")+" command in an empty directory.",
@ -425,7 +425,7 @@ func getCmdRootHelpCommands(cmd *cobra.Command) (result string) {
var paragraph []string
for _, title := range groups {
paragraph = append(paragraph, fmt.Sprintf(" %s\n %s\n",
output.WithBold(string(title)),
output.WithBold("%s", string(title)),
strings.Join(commandGroups[string(title)], "\n ")))
}
return strings.Join(paragraph, "\n")

Просмотреть файл

@ -4,12 +4,11 @@ import (
"context"
"encoding/json"
"io/fs"
"maps"
"os"
"path/filepath"
"slices"
"strings"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)
type PackagesJson struct {
@ -90,14 +89,14 @@ func (nd *javaScriptDetector) DetectProject(ctx context.Context, path string, en
}
if len(databaseDepMap) > 0 {
project.DatabaseDeps = maps.Keys(databaseDepMap)
slices.SortFunc(project.DatabaseDeps, func(a, b DatabaseDep) bool {
return string(a) < string(b)
})
project.DatabaseDeps = slices.SortedFunc(maps.Keys(databaseDepMap),
func(a, b DatabaseDep) int {
return strings.Compare(string(a), string(b))
})
}
slices.SortFunc(project.Dependencies, func(a, b Dependency) bool {
return string(a) < string(b)
slices.SortFunc(project.Dependencies, func(a, b Dependency) int {
return strings.Compare(string(a), string(b))
})
tsFiles := 0

Просмотреть файл

@ -4,12 +4,11 @@ import (
"bufio"
"context"
"io/fs"
"maps"
"os"
"path/filepath"
"slices"
"strings"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)
type pythonDetector struct {
@ -82,14 +81,14 @@ func (pd *pythonDetector) DetectProject(ctx context.Context, path string, entrie
}
if len(databaseDepMap) > 0 {
project.DatabaseDeps = maps.Keys(databaseDepMap)
slices.SortFunc(project.DatabaseDeps, func(a, b DatabaseDep) bool {
return string(a) < string(b)
})
project.DatabaseDeps = slices.SortedFunc(maps.Keys(databaseDepMap),
func(a, b DatabaseDep) int {
return strings.Compare(string(a), string(b))
})
}
slices.SortFunc(project.Dependencies, func(a, b Dependency) bool {
return string(a) < string(b)
slices.SortFunc(project.Dependencies, func(a, b Dependency) int {
return strings.Compare(string(a), string(b))
})
return project, nil

Просмотреть файл

@ -36,7 +36,7 @@ func generateCmdHelpSamplesBlock(samples map[string]string) string {
// sorting lines to keep a deterministic output, as map[string]string is not ordered
slices.Sort(lines)
return fmt.Sprintf("%s\n%s\n",
output.WithBold(output.WithUnderline("Examples")),
output.WithBold("%s", output.WithUnderline("Examples")),
strings.Join(lines, "\n\n"),
)
}

Просмотреть файл

@ -268,19 +268,19 @@ func (p *ProvisionAction) Run(ctx context.Context) (*actions.ActionResult, error
requestAccessLink := "https://go.microsoft.com/fwlink/?linkid=2259205&clcid=0x409"
return nil, &internal.ErrorWithSuggestion{
Err: err,
Suggestion: fmt.Sprintf("\nSuggested Action: The selected subscription does not have access to" +
" Azure OpenAI Services. Please visit " + output.WithLinkFormat(requestAccessLink) +
" to request access."),
Suggestion: "\nSuggested Action: The selected subscription does not have access to" +
" Azure OpenAI Services. Please visit " + output.WithLinkFormat("%s", requestAccessLink) +
" to request access.",
}
}
if strings.Contains(errorMsg, AINotValid) &&
strings.Contains(errorMsg, openAIsubscriptionNoQuotaId) {
return nil, &internal.ErrorWithSuggestion{
Suggestion: fmt.Sprintf("\nSuggested Action: The selected " +
Suggestion: "\nSuggested Action: The selected " +
"subscription has not been enabled for use of Azure AI service and does not have quota for " +
"any pricing tiers. Please visit " + output.WithLinkFormat(p.portalUrlBase) +
" and select 'Create' on specific services to request access."),
"any pricing tiers. Please visit " + output.WithLinkFormat("%s", p.portalUrlBase) +
" and select 'Create' on specific services to request access.",
Err: err,
}
}
@ -288,10 +288,10 @@ func (p *ProvisionAction) Run(ctx context.Context) (*actions.ActionResult, error
//if user haven't agree to Responsible AI terms
if strings.Contains(errorMsg, responsibleAITerms) {
return nil, &internal.ErrorWithSuggestion{
Suggestion: fmt.Sprintf("\nSuggested Action: Please visit azure portal in " +
output.WithLinkFormat(p.portalUrlBase) + ". Create the resource in azure portal " +
Suggestion: "\nSuggested Action: Please visit azure portal in " +
output.WithLinkFormat("%s", p.portalUrlBase) + ". Create the resource in azure portal " +
"to go through Responsible AI terms, and then delete it. " +
"After that, run 'azd provision' again"),
"After that, run 'azd provision' again",
Err: err,
}
}

Просмотреть файл

@ -5,8 +5,11 @@ import (
"errors"
"fmt"
"log"
"maps"
"os"
"path/filepath"
"slices"
"strings"
"time"
"github.com/AlecAivazis/survey/v2/terminal"
@ -18,8 +21,6 @@ import (
"github.com/azure/azure-dev/cli/azd/pkg/output/ux"
"github.com/fatih/color"
"go.opentelemetry.io/otel/attribute"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)
func projectDisplayName(p appdetect.Project) string {
@ -244,7 +245,7 @@ func (d *detectConfirm) remove(ctx context.Context) error {
modifyOptions, fmt.Sprintf("%s in %s", projectDisplayName(svc), relSafe(d.root, svc.Path)))
}
displayDbs := maps.Keys(d.Databases)
displayDbs := slices.Collect(maps.Keys(d.Databases))
for _, db := range displayDbs {
modifyOptions = append(modifyOptions, db.Display())
}
@ -307,26 +308,26 @@ func (d *detectConfirm) remove(ctx context.Context) error {
}
func (d *detectConfirm) add(ctx context.Context) error {
languages := maps.Keys(languageMap)
slices.SortFunc(languages, func(a, b appdetect.Language) bool {
return a.Display() < b.Display()
})
languages := slices.SortedFunc(maps.Keys(languageMap),
func(a, b appdetect.Language) int {
return strings.Compare(a.Display(), b.Display())
})
frameworks := maps.Keys(appdetect.WebUIFrameworks)
slices.SortFunc(frameworks, func(a, b appdetect.Dependency) bool {
return a.Display() < b.Display()
})
frameworks := slices.SortedFunc(maps.Keys(appdetect.WebUIFrameworks),
func(a, b appdetect.Dependency) int {
return strings.Compare(a.Display(), b.Display())
})
// only include databases not already added
allDbs := maps.Keys(dbMap)
allDbs := slices.Collect(maps.Keys(dbMap))
databases := make([]appdetect.DatabaseDep, 0, len(allDbs))
for _, db := range allDbs {
if _, ok := d.Databases[db]; !ok {
databases = append(databases, db)
}
}
slices.SortFunc(databases, func(a, b appdetect.DatabaseDep) bool {
return a.Display() < b.Display()
slices.SortFunc(databases, func(a, b appdetect.DatabaseDep) int {
return strings.Compare(a.Display(), b.Display())
})
selections := make([]string, 0, len(languages)+len(frameworks)+len(databases))

Просмотреть файл

@ -43,9 +43,10 @@ func (tq *InMemoryTelemetryQueue) EnqueueWithDelay(message []byte, delayDuration
}
func (tq *InMemoryTelemetryQueue) save(message []byte, delayDuration time.Duration, retryCount int) error {
/* #nosec G404 - Use of weak random number generator - false positive in test */
//nolint:gosec // G404 - Use of weak random number generator - false positive in test
fileName := strconv.FormatUint(rand.Uint64(), 10)
/* #nosec G404 - Use of weak random number generator - false positive in test */
//nolint:gosec // G404 - Use of weak random number generator - false positive in test
for _, exists := tq.itemMap[fileName]; exists; fileName = strconv.FormatUint(rand.Uint64(), 10) {
}

Просмотреть файл

@ -4,7 +4,8 @@
package baggage
import (
"golang.org/x/exp/maps"
"maps"
"slices"
"go.opentelemetry.io/otel/attribute"
)
@ -73,7 +74,7 @@ func (mb Baggage) Get(key attribute.Key) attribute.Value {
// Keys returns a copy of the keys contained.
func (mb Baggage) Keys() []attribute.Key {
return maps.Keys(mb.m)
return slices.Collect(maps.Keys(mb.m))
}
// Attributes returns a copy of the key-value attributes contained.

Просмотреть файл

@ -8,6 +8,7 @@ import (
"hash/fnv"
"io/fs"
"log"
"maps"
"os"
"path/filepath"
"regexp"
@ -28,7 +29,6 @@ import (
"github.com/azure/azure-dev/cli/azd/pkg/output"
"github.com/azure/azure-dev/cli/azd/resources"
"github.com/psanford/memfs"
"golang.org/x/exp/maps"
"gopkg.in/yaml.v3"
)
@ -269,9 +269,7 @@ func BicepTemplate(name string, manifest *Manifest, options AppHostOptions) (*me
var mapToResourceParams []genInput
// order to be deterministic when writing bicep
genParametersKeys := maps.Keys(generator.bicepContext.InputParameters)
slices.Sort(genParametersKeys)
genParametersKeys := slices.Sorted(maps.Keys(generator.bicepContext.InputParameters))
for _, key := range genParametersKeys {
parameter := generator.bicepContext.InputParameters[key]
parameterMetadata := ""

Просмотреть файл

@ -659,13 +659,13 @@ func (m *Manager) LoginWithDeviceCode(
"Cloud Shell is automatically authenticated under the initial account used to sign in. Run 'azd auth login' only if you need to use a different account.",
fmt.Sprintf(
"To sign in, use a web browser to open the page %s and enter the code %s to authenticate.",
output.WithUnderline(url),
output.WithBold(code.UserCode()),
output.WithUnderline("%s", url),
output.WithBold("%s", code.UserCode()),
),
},
})
} else {
m.console.Message(ctx, fmt.Sprintf("Start by copying the next code: %s", output.WithBold(code.UserCode())))
m.console.Message(ctx, fmt.Sprintf("Start by copying the next code: %s", output.WithBold("%s", code.UserCode())))
if err := withOpenUrl(url); err != nil {
log.Println("error launching browser: ", err.Error())

Просмотреть файл

@ -4,6 +4,7 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
"time"
@ -100,7 +101,7 @@ func (rc *RemoteCredential) GetToken(ctx context.Context, options policy.TokenRe
*tokenResp.Code,
*tokenResp.Message))
default:
return azcore.AccessToken{}, remoteCredentialError("unexpected status", fmt.Errorf(tokenResp.Status))
return azcore.AccessToken{}, remoteCredentialError("unexpected status", errors.New(tokenResp.Status))
}
}

Просмотреть файл

@ -177,9 +177,9 @@ func getDefinitionVariables(
for _, key := range remoteStateKeys {
value, ok := env.LookupEnv(key)
if !ok || strings.TrimSpace(value) == "" {
return nil, fmt.Errorf(fmt.Sprintf(`terraform remote state is not correctly configured,
return nil, fmt.Errorf(`terraform remote state is not correctly configured,
Visit %s for more information on configuring Terraform remote state`,
output.WithLinkFormat("https://aka.ms/azure-dev/terraform")))
output.WithLinkFormat("https://aka.ms/azure-dev/terraform"))
}
variables[key] = createBuildDefinitionVariable(value, false, true)
}

Просмотреть файл

@ -2,6 +2,7 @@ package azsdk
import (
"context"
"errors"
"fmt"
"io"
"net/http"
@ -239,11 +240,11 @@ func logWebAppDeploymentStatus(
}
logErrorFunction(properties, "runtime ")
return fmt.Errorf(errorString)
return errors.New(errorString)
case armappservice.DeploymentBuildStatusBuildFailed:
errorString += "Deployment failed because the build process failed\n"
logErrorFunction(properties, "build ")
return fmt.Errorf(errorString)
return errors.New(errorString)
// Progress Log for other states
default:
if len(status) > 0 {

Просмотреть файл

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"regexp"
"slices"
"strings"
"sync"
@ -14,7 +15,6 @@ import (
"github.com/azure/azure-dev/cli/azd/pkg/infra"
"github.com/azure/azure-dev/cli/azd/pkg/infra/provisioning"
"go.uber.org/multierr"
"golang.org/x/exp/slices"
)
// ADE Bicep deployments have a name of a date like string followed by a number
@ -263,8 +263,8 @@ func (m *manager) LatestArmDeployment(
}
// Sorts the deployments by timestamp in descending order
slices.SortFunc(deployments, func(x, y *armresources.DeploymentExtended) bool {
return x.Properties.Timestamp.After(*y.Properties.Timestamp)
slices.SortFunc(deployments, func(x, y *armresources.DeploymentExtended) int {
return x.Properties.Timestamp.Compare(*y.Properties.Timestamp)
})
latestDeploymentIndex := slices.IndexFunc(deployments, func(d *armresources.DeploymentExtended) bool {

Просмотреть файл

@ -3,13 +3,13 @@ package devcenter
import (
"context"
"fmt"
"slices"
"strconv"
"strings"
"github.com/azure/azure-dev/cli/azd/pkg/devcentersdk"
"github.com/azure/azure-dev/cli/azd/pkg/environment"
"github.com/azure/azure-dev/cli/azd/pkg/input"
"golang.org/x/exp/slices"
)
// Prompter provides a common set of methods for prompting the user for devcenter configuration values
@ -67,8 +67,8 @@ func (p *Prompter) PromptProject(ctx context.Context, devCenterName string) (*de
return nil, fmt.Errorf("no dev center projects found")
}
slices.SortFunc(writeableProjects, func(x, y *devcentersdk.Project) bool {
return x.Name < y.Name
slices.SortFunc(writeableProjects, func(x, y *devcentersdk.Project) int {
return strings.Compare(x.Name, y.Name)
})
// Filter to only projects that match the specified devcenter
@ -132,8 +132,8 @@ func (p *Prompter) PromptEnvironmentType(
}
envTypes := envTypesResponse.Value
slices.SortFunc(envTypes, func(x, y *devcentersdk.EnvironmentType) bool {
return x.Name < y.Name
slices.SortFunc(envTypes, func(x, y *devcentersdk.EnvironmentType) int {
return strings.Compare(x.Name, y.Name)
})
if len(envTypes) == 0 {
@ -177,8 +177,8 @@ func (p *Prompter) PromptEnvironmentDefinition(
}
environmentDefinitions := envDefinitionsResponse.Value
slices.SortFunc(environmentDefinitions, func(x, y *devcentersdk.EnvironmentDefinition) bool {
return x.Name < y.Name
slices.SortFunc(environmentDefinitions, func(x, y *devcentersdk.EnvironmentDefinition) int {
return strings.Compare(x.Name, y.Name)
})
if len(environmentDefinitions) == 0 {
@ -273,7 +273,7 @@ func (p *Prompter) PromptParameters(
}
paramValue = confirmValue
case devcentersdk.ParameterTypeString:
if param.Allowed != nil && len(param.Allowed) > 0 {
if len(param.Allowed) > 0 {
selectedIndex, err := p.console.Select(ctx, promptOptions)
if err != nil {
return nil, fmt.Errorf("failed to prompt for %s: %w", param.Name, err)

Просмотреть файл

@ -5,7 +5,9 @@ import (
"errors"
"fmt"
"log"
"maps"
"os"
"slices"
"strconv"
"strings"
"time"
@ -18,7 +20,6 @@ import (
"github.com/azure/azure-dev/cli/azd/pkg/infra/provisioning"
"github.com/azure/azure-dev/cli/azd/pkg/input"
"github.com/azure/azure-dev/cli/azd/pkg/output"
"golang.org/x/exp/maps"
)
const (
@ -334,7 +335,7 @@ func (p *ProvisionProvider) Destroy(
p.console.StopSpinner(ctx, spinnerMessage, input.StepDone)
result := &provisioning.DestroyResult{
InvalidatedEnvKeys: maps.Keys(outputs),
InvalidatedEnvKeys: slices.Collect(maps.Keys(outputs)),
}
return result, nil

Просмотреть файл

@ -3,13 +3,13 @@ package devcenter
import (
"context"
"fmt"
"slices"
"strings"
"sync"
"github.com/azure/azure-dev/cli/azd/pkg/devcentersdk"
"github.com/azure/azure-dev/cli/azd/pkg/templates"
"go.uber.org/multierr"
"golang.org/x/exp/slices"
)
const (
@ -112,7 +112,7 @@ func (s *TemplateSource) ListTemplates(ctx context.Context) ([]*templates.Templa
// Repo url parameter can support multiple values
// Values can either have a default or multiple allowed values but not both
if p.Allowed != nil && len(p.Allowed) > 0 {
if len(p.Allowed) > 0 {
repoUrls = append(repoUrls, p.Allowed...)
} else if p.Default != nil {
defaultValue, ok := p.Default.(string)

Просмотреть файл

@ -6,6 +6,8 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"strings"
"github.com/azure/azure-dev/cli/azd/internal/tracing"
"github.com/azure/azure-dev/cli/azd/internal/tracing/fields"
@ -14,7 +16,6 @@ import (
"github.com/azure/azure-dev/cli/azd/pkg/environment/azdcontext"
"github.com/google/uuid"
"github.com/joho/godotenv"
"golang.org/x/exp/slices"
)
// LocalFileDataStore is a DataStore implementation that stores environment data in the local file system.
@ -71,8 +72,8 @@ func (fs *LocalFileDataStore) List(ctx context.Context) ([]*contracts.EnvListEnv
}
}
slices.SortFunc(envs, func(a, b *contracts.EnvListEnvironment) bool {
return a.Name < b.Name
slices.SortFunc(envs, func(a, b *contracts.EnvListEnvironment) int {
return strings.Compare(a.Name, b.Name)
})
return envs, nil

Просмотреть файл

@ -4,6 +4,8 @@ import (
"context"
"errors"
"fmt"
"slices"
"strings"
"github.com/MakeNowJust/heredoc/v2"
"github.com/azure/azure-dev/cli/azd/pkg/environment/azdcontext"
@ -11,7 +13,6 @@ import (
"github.com/azure/azure-dev/cli/azd/pkg/ioc"
"github.com/azure/azure-dev/cli/azd/pkg/output/ux"
"github.com/azure/azure-dev/cli/azd/pkg/state"
"golang.org/x/exp/slices"
)
// Description is a metadata description of an environment returned for the `azd env list` command
@ -123,7 +124,7 @@ func (m *manager) Create(ctx context.Context, spec Spec) (*Environment, error) {
if spec.Name != "" && !IsValidEnvironmentName(spec.Name) {
errMsg := invalidEnvironmentNameMsg(spec.Name)
m.console.Message(ctx, errMsg)
return nil, fmt.Errorf(errMsg)
return nil, errors.New(errMsg)
}
if err := m.ensureValidEnvironmentName(ctx, &spec); err != nil {
@ -335,8 +336,8 @@ func (m *manager) List(ctx context.Context) ([]*Description, error) {
allEnvs = append(allEnvs, env)
}
slices.SortFunc(allEnvs, func(a, b *Description) bool {
return a.Name < b.Name
slices.SortFunc(allEnvs, func(a, b *Description) int {
return strings.Compare(a.Name, b.Name)
})
return allEnvs, nil

Просмотреть файл

@ -7,6 +7,8 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"strings"
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/azure/azure-dev/cli/azd/internal/tracing"
@ -16,7 +18,6 @@ import (
"github.com/azure/azure-dev/cli/azd/pkg/contracts"
"github.com/google/uuid"
"github.com/joho/godotenv"
"golang.org/x/exp/slices"
)
var (
@ -83,8 +84,8 @@ func (sbd *StorageBlobDataStore) List(ctx context.Context) ([]*contracts.EnvList
envs = append(envs, env)
}
slices.SortFunc(envs, func(a, b *contracts.EnvListEnvironment) bool {
return a.Name < b.Name
slices.SortFunc(envs, func(a, b *contracts.EnvListEnvironment) int {
return strings.Compare(a.Name, b.Name)
})
return envs, nil

Просмотреть файл

@ -1,4 +1,4 @@
// go:build unix
//go:build unix
package exec

Просмотреть файл

@ -14,6 +14,7 @@ import (
"github.com/azure/azure-dev/cli/azd/internal"
"github.com/azure/azure-dev/cli/azd/internal/tracing/resource"
"github.com/azure/azure-dev/cli/azd/pkg/osutil"
"github.com/azure/azure-dev/cli/azd/test/mocks/mockhttp"
"github.com/stretchr/testify/require"
)
@ -143,7 +144,7 @@ func TestCache(t *testing.T) {
cacheFile.ExpiresOn = time.Now().UTC().Add(-1 * time.Hour)
cacheData, err = json.Marshal(cacheFile)
require.NoError(t, err)
err = os.WriteFile(filepath.Join(cacheRoot, cacheEntries[0].Name()), cacheData, os.ModePerm)
err = os.WriteFile(filepath.Join(cacheRoot, cacheEntries[0].Name()), cacheData, osutil.PermissionFileOwnerOnly)
require.NoError(t, err)
// We'll return a new assigment context from the mock HTTP server, to simulate the

Просмотреть файл

@ -172,7 +172,7 @@ func (h *HooksRunner) execHook(ctx context.Context, hookConfig *HookConfig, opti
// If an error occurred log the failure but continue
if hookConfig.ContinueOnError {
h.console.Message(ctx, output.WithBold(output.WithWarningFormat("WARNING: %s", execErr.Error())))
h.console.Message(ctx, output.WithBold("%s", output.WithWarningFormat("WARNING: %s", execErr.Error())))
h.console.Message(
ctx,
output.WithWarningFormat("Execution will continue since ContinueOnError has been set to true."),

Просмотреть файл

@ -10,6 +10,7 @@ import (
"errors"
"fmt"
"log"
"maps"
"math"
"os"
"path/filepath"
@ -46,7 +47,6 @@ import (
"github.com/azure/azure-dev/cli/azd/pkg/tools/bicep"
"github.com/benbjohnson/clock"
"github.com/drone/envsubst"
"golang.org/x/exp/maps"
)
const (
@ -587,7 +587,7 @@ func (p *BicepProvider) Deploy(ctx context.Context) (*DeployResult, error) {
bicepDeploymentData.CompiledBicep.Template.Parameters, bicepDeploymentData.CompiledBicep.Parameters)
if parametersHashErr != nil {
// fail to hash parameters won't stop the operation. It only disables deployment state and recording parameters hash
logDS(parametersHashErr.Error())
logDS("%s", parametersHashErr.Error())
}
if !p.ignoreDeploymentState && parametersHashErr == nil {
@ -603,7 +603,7 @@ func (p *BicepProvider) Deploy(ctx context.Context) (*DeployResult, error) {
SkippedReason: DeploymentStateSkipped,
}, nil
}
logDS(err.Error())
logDS("%s", err.Error())
}
cancelProgress := make(chan bool)
@ -931,10 +931,10 @@ func (p *BicepProvider) Destroy(ctx context.Context, options DestroyOptions) (*D
}
destroyResult := &DestroyResult{
InvalidatedEnvKeys: maps.Keys(p.createOutputParameters(
InvalidatedEnvKeys: slices.Collect(maps.Keys(p.createOutputParameters(
compileResult.Template.Outputs,
azapi.CreateDeploymentOutput(deployments[0].Properties.Outputs),
)),
))),
}
// Since we have deleted the resource group, add AZURE_RESOURCE_GROUP to the list of invalidated env vars
@ -1099,7 +1099,7 @@ func resourceGroupsToDelete(deployment *armresources.DeploymentExtended) []strin
}
}
return maps.Keys(resourceGroups)
return slices.Collect(maps.Keys(resourceGroups))
}
func (p *BicepProvider) getAllResourcesToDelete(
@ -1955,8 +1955,7 @@ func (p *BicepProvider) ensureParameters(
}
configuredParameters := make(azure.ArmParameters, len(template.Parameters))
sortedKeys := maps.Keys(template.Parameters)
slices.Sort(sortedKeys)
sortedKeys := slices.Sorted(maps.Keys(template.Parameters))
configModified := false

Просмотреть файл

@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"slices"
"strconv"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
@ -12,7 +13,6 @@ import (
"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/password"
"golang.org/x/exp/slices"
. "github.com/azure/azure-dev/cli/azd/pkg/infra/provisioning"
)

Просмотреть файл

@ -200,9 +200,9 @@ func azdFileShareUploadOperations(infraPath string, env environment.Environment)
return fileShareUploadOperations, nil
}
var ErrAzdOperationsNotEnabled = fmt.Errorf(fmt.Sprintf(
var ErrAzdOperationsNotEnabled = fmt.Errorf(
"azd operations (alpha feature) is required but disabled. You can enable azd operations by running: %s",
output.WithGrayFormat(alpha.GetEnableCommand(AzdOperationsFeatureKey))))
output.WithGrayFormat("%s", alpha.GetEnableCommand(AzdOperationsFeatureKey)))
var ErrBindMountOperationDisabled = fmt.Errorf(
"%sYour project has bind mounts.\n - %w\n%s\n",

Просмотреть файл

@ -5,8 +5,10 @@ import (
"encoding/json"
"fmt"
"log"
"maps"
"os"
"path/filepath"
"slices"
"strings"
"github.com/azure/azure-dev/cli/azd/internal"
@ -19,7 +21,6 @@ import (
"github.com/azure/azure-dev/cli/azd/pkg/tools/terraform"
"github.com/drone/envsubst"
"go.opentelemetry.io/otel/trace"
"golang.org/x/exp/maps"
)
const (
@ -262,7 +263,7 @@ func (t *TerraformProvider) Destroy(ctx context.Context, options DestroyOptions)
}
return &DestroyResult{
InvalidatedEnvKeys: maps.Keys(outputs),
InvalidatedEnvKeys: slices.Collect(maps.Keys(outputs)),
}, nil
}

Просмотреть файл

@ -24,10 +24,10 @@ func (t *MessageTitle) ToString(currentIndentation string) string {
}
return fmt.Sprintf("\n%s\n%s\n",
output.WithBold(t.Title),
output.WithGrayFormat(t.TitleNote))
output.WithBold("%s", t.Title),
output.WithGrayFormat("%s", t.TitleNote))
}
return fmt.Sprintf("\n%s\n", output.WithBold(t.Title))
return fmt.Sprintf("\n%s\n", output.WithBold("%s", t.Title))
}
func (t *MessageTitle) MarshalJSON() ([]byte, error) {

Просмотреть файл

@ -12,6 +12,7 @@ import (
"net/url"
"path/filepath"
"regexp"
"slices"
"strings"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
@ -27,7 +28,6 @@ import (
"github.com/azure/azure-dev/cli/azd/pkg/tools"
"github.com/azure/azure-dev/cli/azd/pkg/tools/git"
"github.com/azure/azure-dev/cli/azd/pkg/tools/github"
"golang.org/x/exp/slices"
)
// GitHubScmProvider implements ScmProvider using GitHub as the provider

Просмотреть файл

@ -12,6 +12,7 @@ import (
"log"
"os"
"path/filepath"
"slices"
"strings"
"time"
@ -32,7 +33,6 @@ import (
"github.com/azure/azure-dev/cli/azd/resources"
"github.com/google/uuid"
"github.com/sethvargo/go-retry"
"golang.org/x/exp/slices"
)
type PipelineAuthType string
@ -866,7 +866,7 @@ func (pm *PipelineManager) checkAndPromptForProviderFiles(ctx context.Context, p
pipelineProviderFiles[props.CiProvider].DisplayName,
strings.Join(pipelineProviderFiles[props.CiProvider].PipelineDirectories, "\n"))
log.Println("Error:", message)
return fmt.Errorf(message)
return errors.New(message)
}
log.Println("Info:", message)

Просмотреть файл

@ -7,6 +7,7 @@ import (
"log"
"os"
"path/filepath"
"slices"
"strings"
"github.com/azure/azure-dev/cli/azd/internal"
@ -17,7 +18,6 @@ import (
"github.com/azure/azure-dev/cli/azd/pkg/infra/provisioning"
"github.com/azure/azure-dev/cli/azd/pkg/osutil"
"github.com/blang/semver/v4"
"golang.org/x/exp/slices"
"gopkg.in/yaml.v3"
)

Просмотреть файл

@ -2,6 +2,7 @@ package prompt
import (
"context"
"errors"
"fmt"
"log"
"os"
@ -59,7 +60,7 @@ func (p *DefaultPrompter) PromptSubscription(ctx context.Context, msg string) (s
}
if len(subscriptionOptions) == 0 {
return "", fmt.Errorf(heredoc.Docf(
return "", errors.New(heredoc.Docf(
`no subscriptions found.
Ensure you have a subscription by visiting %s and search for Subscriptions in the search bar.
Once you have a subscription, run 'azd auth login' again to reload subscriptions.`,

Просмотреть файл

@ -4,8 +4,7 @@ import (
"context"
"fmt"
"log"
"golang.org/x/exp/slices"
"slices"
)
// Source is a source of AZD compatible templates.

Просмотреть файл

@ -104,7 +104,7 @@ func (sm *sourceManager) List(ctx context.Context) ([]*SourceConfig, error) {
allSourceConfigs := []*SourceConfig{}
if sm.options.DefaultSources != nil && len(sm.options.DefaultSources) > 0 {
if len(sm.options.DefaultSources) > 0 {
allSourceConfigs = append(allSourceConfigs, sm.options.DefaultSources...)
}

Просмотреть файл

@ -4,10 +4,10 @@ import (
"context"
"fmt"
"log"
"slices"
"strings"
"github.com/azure/azure-dev/cli/azd/pkg/input"
"golang.org/x/exp/slices"
)
var (
@ -88,16 +88,16 @@ func (tm *TemplateManager) ListTemplates(ctx context.Context, options *ListOptio
}
// Sort by source, then repository path and finally name
slices.SortFunc(filteredTemplates, func(a *Template, b *Template) bool {
slices.SortFunc(filteredTemplates, func(a *Template, b *Template) int {
if a.Source != b.Source {
return a.Source < b.Source
return strings.Compare(a.Source, b.Source)
}
if a.RepositoryPath != b.RepositoryPath {
return a.RepositoryPath < b.RepositoryPath
return strings.Compare(a.RepositoryPath, b.RepositoryPath)
}
return a.Name < b.Name
return strings.Compare(a.Name, b.Name)
})
allTemplates = append(allTemplates, filteredTemplates...)

Просмотреть файл

@ -125,7 +125,7 @@ func getMavenWrapperPath(projectPath string, rootProjectPath string) (string, er
return mvnw, nil
}
if !errors.Is(err, os.ErrNotExist) {
if !errors.Is(err, os.ErrNotExist) && !errors.Is(err, osexec.ErrNotFound) {
return "", err
}

Просмотреть файл

@ -108,7 +108,7 @@ func (p *recorderProxy) ServeConn(conn io.Writer, req *http.Request) {
resp, err := p.Recorder.RoundTrip(req)
if err != nil {
p.panic(fmt.Sprintf("%s %s: %s", req.Method, req.URL.String(), err.Error()))
p.panic("%s", fmt.Sprintf("%s %s: %s", req.Method, req.URL.String(), err.Error()))
}
if err != nil {
@ -130,7 +130,7 @@ func (p *recorderProxy) ServeConn(conn io.Writer, req *http.Request) {
err = resp.Write(conn)
if err != nil {
p.panic(err.Error())
p.panic("%s", err.Error())
}
}

Просмотреть файл

@ -475,7 +475,7 @@ func (l *logWriter) Write(bytes []byte) (n int, err error) {
}
if b == '\n' {
l.t.Logf(l.sb.String())
l.t.Logf("%s", l.sb.String())
l.sb.Reset()
}
}

Просмотреть файл

@ -1,5 +1,5 @@
parameters:
GoVersion: 1.21.0
GoVersion: 1.23.0
Condition: succeeded()
steps:

4
go.mod
Просмотреть файл

@ -1,6 +1,6 @@
module github.com/azure/azure-dev
go 1.21
go 1.23
require (
github.com/AlecAivazis/survey/v2 v2.3.2
@ -66,7 +66,6 @@ require (
go.opentelemetry.io/otel/trace v1.8.0
go.uber.org/atomic v1.9.0
go.uber.org/multierr v1.8.0
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1
golang.org/x/sys v0.21.0
gopkg.in/dnaeon/go-vcr.v3 v3.1.2
gopkg.in/yaml.v3 v3.0.1
@ -82,6 +81,7 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect

6
go.sum
Просмотреть файл

@ -270,8 +270,8 @@ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
@ -574,8 +574,6 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=