-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from local-deploy/CU-86950pntz
feat(config): command to disable running service containers
- Loading branch information
Showing
4 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package command | ||
|
||
import ( | ||
"log" | ||
|
||
"atomicgo.dev/keyboard/keys" | ||
"github.com/pterm/pterm" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func configServiceCommand() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "service", | ||
Short: "Additional service containers", | ||
Long: `Menu for managing the launch of additional containers (portainer and mailhog).`, | ||
Run: func(_ *cobra.Command, _ []string) { | ||
configServiceRun() | ||
}, | ||
Hidden: false, | ||
} | ||
return cmd | ||
} | ||
|
||
func configServiceRun() { | ||
hasKeys := viper.IsSet("services") | ||
currentServices := viper.GetStringSlice("services") | ||
if !hasKeys { | ||
currentServices = append(currentServices, "portainer", "mail") | ||
} | ||
options := []string{"portainer", "mail"} | ||
selectedOption, _ := pterm.DefaultInteractiveMultiselect. | ||
WithOptions(options). | ||
WithFilter(false). | ||
WithKeySelect(keys.Space). | ||
WithKeyConfirm(keys.Enter). | ||
WithDefaultOptions(currentServices). | ||
Show("Select the services that should be started with the 'dl service up' command") | ||
pterm.Printfln("Selected services: %s", pterm.Green(selectedOption)) | ||
|
||
saveServiceConfig(selectedOption) | ||
} | ||
|
||
func saveServiceConfig(lang interface{}) { | ||
viper.Set("services", lang) | ||
err := viper.WriteConfig() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters