From 0372b3f924c5a1928073962b345ac8faf7544889 Mon Sep 17 00:00:00 2001 From: Lionello Lunesu Date: Thu, 4 Jul 2024 17:31:28 -0700 Subject: [PATCH 1/2] fix regressions in generate --- src/cmd/cli/command/commands.go | 15 ++++++++------- src/cmd/cli/command/hint.go | 12 ++++++++---- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/cmd/cli/command/commands.go b/src/cmd/cli/command/commands.go index 65fd7efd7..0ee653606 100644 --- a/src/cmd/cli/command/commands.go +++ b/src/cmd/cli/command/commands.go @@ -563,11 +563,11 @@ var generateCmd = &cobra.Command{ term.Info("Code generated successfully in folder", prompt.Folder) - // TODO: should we use EDITOR env var instead? - cmdd := exec.Command("code", ".") + cmdd := exec.Command("code", prompt.Folder) err = cmdd.Start() if err != nil { term.Debug("unable to launch VS Code:", err) + // TODO: should we use EDITOR env var instead? } cd := "" @@ -576,15 +576,16 @@ var generateCmd = &cobra.Command{ } // Load the project and check for empty environment variables - var envInstructions = "" loader := compose.Loader{ComposeFilePath: filepath.Join(prompt.Folder, "compose.yaml")} project, _ := loader.LoadCompose(cmd.Context()) - envVars := collectUnsetEnvVars(project) // if err != nil -> proj == nil, which is handled in the collectUnsetEnvVars function - envInstructions = strings.Join(envVars, " ") + var envInstructions []string + for _, envVar := range collectUnsetEnvVars(project) { + envInstructions = append(envInstructions, "config create "+envVar) + } - if envInstructions != "" { // logic needs to be duplicated in case where no env vars in yaml file. - printDefangHint("Check the files in your favorite editor.\nTo deploy the service, do "+cd, "config set "+envInstructions) + if len(envInstructions) > 0 { + printDefangHint("Check the files in your favorite editor.\nTo deploy the service, do "+cd, envInstructions...) } else { printDefangHint("Check the files in your favorite editor.\nTo deploy the service, do "+cd, "compose up") } diff --git a/src/cmd/cli/command/hint.go b/src/cmd/cli/command/hint.go index 4ebce0651..266e9bd16 100644 --- a/src/cmd/cli/command/hint.go +++ b/src/cmd/cli/command/hint.go @@ -33,7 +33,7 @@ func prettyExecutable(def string) string { return executable } -func printDefangHint(hint, args string) { +func printDefangHint(hint string, cmds ...string) { if pkg.GetenvBool("DEFANG_HIDE_HINTS") || !hasTty { return } @@ -43,12 +43,16 @@ func printDefangHint(hint, args string) { fmt.Printf("\n%s\n", hint) providerFlag := RootCmd.Flag("provider") clusterFlag := RootCmd.Flag("cluster") + var prefix string if providerFlag.Changed { - fmt.Printf("\n %s --provider %s %s\n\n", executable, providerFlag.Value.String(), args) + prefix = fmt.Sprintf("%s --provider %s", executable, providerFlag.Value.String()) } else if clusterFlag.Changed { - fmt.Printf("\n %s --cluster %s %s\n\n", executable, clusterFlag.Value.String(), args) + prefix = fmt.Sprintf("%s --cluster %s", executable, clusterFlag.Value.String()) } else { - fmt.Printf("\n %s %s\n\n", executable, args) + prefix = executable + } + for _, arg := range cmds { + fmt.Printf("\n %s %s\n", prefix, arg) } if rand.Intn(10) == 0 { fmt.Println("To silence these hints, do: export DEFANG_HIDE_HINTS=1") From b863e1a8f184c7178b4f1bb4190cdeb5d4931984 Mon Sep 17 00:00:00 2001 From: Lionello Lunesu Date: Fri, 5 Jul 2024 08:48:15 -0700 Subject: [PATCH 2/2] fix CI --- .github/workflows/go.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 7e4af35b2..884ec5cf8 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -119,6 +119,7 @@ jobs: build-and-sign: name: Build app and sign files (with Trusted Signing) + if: startsWith(github.ref, 'refs/tags/v') # only run this step on tagged commits environment: release # must use environment to be able to authenticate with Azure Federated Identity for Trusted Signing needs: go-test runs-on: windows-latest @@ -169,6 +170,7 @@ jobs: client-id: ${{ secrets.AZURE_CLIENT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }} subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + - name: Trusted Signing uses: Azure/trusted-signing-action@v0.3.20 if: startsWith(github.ref, 'refs/tags/v') # only run this step on tagged commits