Skip to content

Commit 3ee6961

Browse files
Go 1.19, dependabot configuration and smaller improvements
several small improvements
2 parents 955122b + 397ea2f commit 3ee6961

8 files changed

Lines changed: 36 additions & 39 deletions

File tree

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gomod"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"

.github/workflows/ci_pipe.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Set up Go
2020
uses: actions/setup-go@v3
2121
with:
22-
go-version: 1.18
22+
go-version: 1.19
2323

2424
- name: Run Unit Tests
2525
run: make test -B

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ dockware-cli creator
4242

4343
The output should then look like this. Just continue answering the questions and you'll end up with a nice docker-compose.yml file.
4444

45-
```bash
45+
```
4646
Dockware Creator
4747
4848
? What do you want to do? [Use arrows to move, type to filter]

cmd/creator.go

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
dc "github.com/dockware/dockware-cli/dockercompose"
77
"github.com/spf13/cobra"
88
"golang.org/x/term"
9+
"log"
910
"os"
1011
"os/exec"
1112
"strings"
@@ -29,9 +30,8 @@ var creatorCmd = &cobra.Command{
2930
Short: "Use the interactive dockware creator to get what you need for today's task",
3031
Long: "",
3132
Run: func(cmd *cobra.Command, args []string) {
32-
if !term.IsTerminal(int(syscall.Stdin)) {
33-
fmt.Println("interactive terminal required")
34-
os.Exit(1)
33+
if !term.IsTerminal(syscall.Stdin) {
34+
log.Fatal("interactive terminal required")
3535
}
3636

3737
a := &Answers{}
@@ -41,7 +41,7 @@ var creatorCmd = &cobra.Command{
4141
case dc.Play:
4242

4343
a.SwVersion = askShopwareVersion(dc.Play.String())
44-
runArgs := []string{"run", "--rm", "--name", "shopware", "-p", "80:80", "-p" , "443:443", fmt.Sprintf("dockware/%s:%s", a.DevIntentString, a.SwVersion)}
44+
runArgs := []string{"run", "--rm", "--name", "shopware", "-p", "80:80", "-p", "443:443", fmt.Sprintf("dockware/%s:%s", a.DevIntentString, a.SwVersion)}
4545

4646
fmt.Printf("All done! Just run the following command in your terminal and enjoy Shopware %s:\n\n", a.SwVersion)
4747
fmt.Printf("docker %s\n\n", strings.Join(runArgs, " "))
@@ -50,8 +50,7 @@ var creatorCmd = &cobra.Command{
5050
Message: "Run the command now?",
5151
}, &execute)
5252
if err != nil {
53-
fmt.Printf("%s\n", err.Error())
54-
os.Exit(1)
53+
log.Fatalf("%s\n", err.Error())
5554
}
5655
if execute {
5756
cmd := exec.Command("docker", runArgs...)
@@ -60,8 +59,7 @@ var creatorCmd = &cobra.Command{
6059
cmd.Stdout = os.Stdout
6160
err := cmd.Run()
6261
if err != nil {
63-
fmt.Println(err.Error())
64-
os.Exit(1)
62+
log.Fatal(err.Error())
6563
}
6664
}
6765
return
@@ -80,14 +78,12 @@ var creatorCmd = &cobra.Command{
8078

8179
composeString, err := dc.BuildDockware("dev", dc.MountType(a.MountType), swVersion, withMySQL, withElastic, withRedis, withAppServer, withPWA)
8280
if err != nil {
83-
fmt.Printf("could not build YAML: %s\n", err.Error())
84-
os.Exit(1)
81+
log.Fatalf("could not build YAML: %s\n", err.Error())
8582
}
8683

8784
err = os.WriteFile("docker-compose.yml", []byte(composeString), 0666)
8885
if err != nil {
89-
fmt.Printf("could not write file: %s\n", err.Error())
90-
os.Exit(1)
86+
log.Fatalf("could not write file: %s\n", err.Error())
9187
}
9288

9389
fmt.Println("File generated: ./docker-compose.yml")
@@ -99,13 +95,12 @@ var creatorCmd = &cobra.Command{
9995

10096
composeString, err := dc.BuildDockware("contribute", dc.MountType(a.MountType), "latest", false, false, false, false, false)
10197
if err != nil {
102-
fmt.Errorf("could not build YAML: %s\n", err.Error())
98+
log.Fatalf("could not build YAML: %s\n", err.Error())
10399
}
104100

105101
err = os.WriteFile("docker-compose.yml", []byte(composeString), 0666)
106102
if err != nil {
107-
fmt.Printf("could not write file: %s\n", err.Error())
108-
os.Exit(1)
103+
log.Fatalf("could not write file: %s\n", err.Error())
109104
}
110105

111106
fmt.Println("File generated: ./docker-compose.yml")
@@ -143,8 +138,7 @@ func (a *Answers) getDevType() {
143138

144139
err := survey.Ask(devTypeQuestion, a)
145140
if err != nil {
146-
fmt.Println(err.Error())
147-
os.Exit(1)
141+
log.Fatal(err.Error())
148142
}
149143
}
150144

@@ -174,8 +168,7 @@ func (a *Answers) getMountType() {
174168
}
175169
err := survey.Ask(asMountType, a)
176170
if err != nil {
177-
fmt.Println(err.Error())
178-
os.Exit(1)
171+
log.Fatal(err.Error())
179172
}
180173
}
181174

@@ -186,7 +179,7 @@ func (a *Answers) getDevIntent() {
186179
dc.Contribute: "Best for contributing changes to the Shopware core",
187180
}
188181
imageTitles := make([]string, len(images))
189-
for i, _ := range images {
182+
for i := range images {
190183
it := dc.DevIntent(i)
191184
imageTitles[i] = it.String()
192185
}
@@ -205,8 +198,7 @@ func (a *Answers) getDevIntent() {
205198
}
206199
err := survey.Ask(askImage, a)
207200
if err != nil {
208-
fmt.Printf("Could not get Dev Intent: %s\n", err.Error())
209-
os.Exit(1)
201+
log.Fatalf("Could not get Dev Intent: %s\n", err.Error())
210202
}
211203
a.DevIntentString = dc.DevIntent(a.DevIntent).String()
212204
}

cmd/root.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,12 @@ import (
99
// rootCmd represents the base command when called without any subcommands
1010
var rootCmd = &cobra.Command{
1111
Use: "dockware",
12-
Short: "A brief description of your application",
13-
Long: `A longer description that spans multiple lines and likely contains
14-
examples and usage of using your application. For example:
15-
16-
Cobra is a CLI library for Go that empowers applications.
17-
This application is a tool to generate the needed files
18-
to quickly create a Cobra application.`,
12+
Short: "Our interactive way of getting started with dockware, docker and Shopware",
13+
Long: `The creator is a tool that helps you to build your Docker setup in an interactive way.
14+
It will guide you through all these questions on what and how you want to develop.
15+
The final result might be a single line to start a Shopware version, or even a full
16+
docker-compose.yml file with all kinds of containers and settings, ready to be used.
17+
And as always, we just try to help you with the onboarding steps to Docker and stick with the standard.`,
1918
// Uncomment the following line if your bare application
2019
// has an action associated with it:
2120
// Run: func(cmd *cobra.Command, args []string) { },

dockercompose/dockercompose.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
)
66
import "gopkg.in/yaml.v3"
77

8-
type dockerCompose struct {
8+
type DockerCompose struct {
99
Version string `yaml:"version"`
1010
Services map[string]*Service `yaml:"services"`
1111
VolumeDrivers map[string]VolumeDriver `yaml:"volumes,omitempty"`
@@ -24,20 +24,20 @@ type Service struct {
2424
Links []string `yaml:"links,omitempty"`
2525
}
2626

27-
func Create(version string) dockerCompose {
28-
return dockerCompose{
27+
func Create(version string) DockerCompose {
28+
return DockerCompose{
2929
Version: version,
3030
Services: map[string]*Service{},
3131
VolumeDrivers: map[string]VolumeDriver{},
3232
}
3333
}
3434

35-
func (dc *dockerCompose) AddOverwriteService(serviceName, containerName, image string) *Service {
35+
func (dc *DockerCompose) AddOverwriteService(serviceName, containerName, image string) *Service {
3636
dc.Services[serviceName] = &Service{ContainerName: containerName, Image: image}
3737
return dc.Services[serviceName]
3838
}
3939

40-
func (dc *dockerCompose) AddVolume(volumeName, driver string) {
40+
func (dc *DockerCompose) AddVolume(volumeName, driver string) {
4141
dc.VolumeDrivers[volumeName] = VolumeDriver{Driver: driver}
4242
}
4343

@@ -69,7 +69,7 @@ func (s *Service) AddEnv(key, value string) {
6969
s.Environment = append(s.Environment, fmt.Sprintf("%s=%s", key, value))
7070
}
7171

72-
func (dc *dockerCompose) ToString() (string, error) {
72+
func (dc *DockerCompose) ToString() (string, error) {
7373
d, err := yaml.Marshal(&dc)
7474
if err != nil {
7575
return "", err

dockercompose/dockercompose_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
func TestCreate(t *testing.T) {
99
got := Create("3.0")
10-
want := &dockerCompose{
10+
want := &DockerCompose{
1111
Version: "3.0",
1212
Services: map[string]*Service{},
1313
VolumeDrivers: map[string]VolumeDriver{},

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/dockware/dockware-cli
22

3-
go 1.18
3+
go 1.19
44

55
require (
66
github.com/AlecAivazis/survey/v2 v2.3.6

0 commit comments

Comments
 (0)