Skip to content

Commit 3b44b83

Browse files
authored
Merge pull request #525 from DefangLabs/lio-fix-generate
fix regressions in generate
2 parents 54bf92a + b863e1a commit 3b44b83

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

.github/workflows/go.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ jobs:
119119

120120
build-and-sign:
121121
name: Build app and sign files (with Trusted Signing)
122+
if: startsWith(github.ref, 'refs/tags/v') # only run this step on tagged commits
122123
environment: release # must use environment to be able to authenticate with Azure Federated Identity for Trusted Signing
123124
needs: go-test
124125
runs-on: windows-latest
@@ -169,6 +170,7 @@ jobs:
169170
client-id: ${{ secrets.AZURE_CLIENT_ID }}
170171
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
171172
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
173+
172174
- name: Trusted Signing
173175
uses: Azure/[email protected]
174176
if: startsWith(github.ref, 'refs/tags/v') # only run this step on tagged commits

src/cmd/cli/command/commands.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,11 @@ var generateCmd = &cobra.Command{
563563

564564
term.Info("Code generated successfully in folder", prompt.Folder)
565565

566-
// TODO: should we use EDITOR env var instead?
567-
cmdd := exec.Command("code", ".")
566+
cmdd := exec.Command("code", prompt.Folder)
568567
err = cmdd.Start()
569568
if err != nil {
570569
term.Debug("unable to launch VS Code:", err)
570+
// TODO: should we use EDITOR env var instead?
571571
}
572572

573573
cd := ""
@@ -576,15 +576,16 @@ var generateCmd = &cobra.Command{
576576
}
577577

578578
// Load the project and check for empty environment variables
579-
var envInstructions = ""
580579
loader := compose.Loader{ComposeFilePath: filepath.Join(prompt.Folder, "compose.yaml")}
581580
project, _ := loader.LoadCompose(cmd.Context())
582581

583-
envVars := collectUnsetEnvVars(project) // if err != nil -> proj == nil, which is handled in the collectUnsetEnvVars function
584-
envInstructions = strings.Join(envVars, " ")
582+
var envInstructions []string
583+
for _, envVar := range collectUnsetEnvVars(project) {
584+
envInstructions = append(envInstructions, "config create "+envVar)
585+
}
585586

586-
if envInstructions != "" { // logic needs to be duplicated in case where no env vars in yaml file.
587-
printDefangHint("Check the files in your favorite editor.\nTo deploy the service, do "+cd, "config set "+envInstructions)
587+
if len(envInstructions) > 0 {
588+
printDefangHint("Check the files in your favorite editor.\nTo deploy the service, do "+cd, envInstructions...)
588589
} else {
589590
printDefangHint("Check the files in your favorite editor.\nTo deploy the service, do "+cd, "compose up")
590591
}

src/cmd/cli/command/hint.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func prettyExecutable(def string) string {
3333
return executable
3434
}
3535

36-
func printDefangHint(hint, args string) {
36+
func printDefangHint(hint string, cmds ...string) {
3737
if pkg.GetenvBool("DEFANG_HIDE_HINTS") || !hasTty {
3838
return
3939
}
@@ -43,12 +43,16 @@ func printDefangHint(hint, args string) {
4343
fmt.Printf("\n%s\n", hint)
4444
providerFlag := RootCmd.Flag("provider")
4545
clusterFlag := RootCmd.Flag("cluster")
46+
var prefix string
4647
if providerFlag.Changed {
47-
fmt.Printf("\n %s --provider %s %s\n\n", executable, providerFlag.Value.String(), args)
48+
prefix = fmt.Sprintf("%s --provider %s", executable, providerFlag.Value.String())
4849
} else if clusterFlag.Changed {
49-
fmt.Printf("\n %s --cluster %s %s\n\n", executable, clusterFlag.Value.String(), args)
50+
prefix = fmt.Sprintf("%s --cluster %s", executable, clusterFlag.Value.String())
5051
} else {
51-
fmt.Printf("\n %s %s\n\n", executable, args)
52+
prefix = executable
53+
}
54+
for _, arg := range cmds {
55+
fmt.Printf("\n %s %s\n", prefix, arg)
5256
}
5357
if rand.Intn(10) == 0 {
5458
fmt.Println("To silence these hints, do: export DEFANG_HIDE_HINTS=1")

0 commit comments

Comments
 (0)