Skip to content

Commit

Permalink
Apply Goreportcard suggestions (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcauberer committed Oct 12, 2021
1 parent 0063a82 commit 4eb43e8
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 20 deletions.
1 change: 1 addition & 0 deletions src/cmd/add.go
Expand Up @@ -44,6 +44,7 @@ var AddCliFlags = []cli.Flag{
},
}

// AddCustomServiceMockable is the mockable version of AddCustomService
var AddCustomServiceMockable = AddCustomService

// ---------------------------------------------------------------- Public functions ---------------------------------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions src/cmd/template-load_test.go
Expand Up @@ -292,10 +292,9 @@ func TestCopyVolumesFromTemplate1(t *testing.T) {
assert.Equal(t, "././Template 1/volume1", src)
assert.Equal(t, "./volume1", dest)
return nil
} else {
assert.Equal(t, "././Template 2/volume3", src)
assert.Equal(t, "../volume3", dest)
}
assert.Equal(t, "././Template 2/volume3", src)
assert.Equal(t, "../volume3", dest)
return errors.New("Error message")
}
printErrorCallCount := 0
Expand Down
5 changes: 2 additions & 3 deletions src/cmd/template-save_test.go
Expand Up @@ -132,10 +132,9 @@ func TestCopyVolumesAndBuildContextsToTemplate1(t *testing.T) {
assert.Equal(t, "./volume1", src)
assert.Equal(t, "../templates/./Template 1/volume1", dest)
return nil
} else {
assert.Equal(t, "frontend-angular", src)
assert.Equal(t, "../templates/", dest)
}
assert.Equal(t, "frontend-angular", src)
assert.Equal(t, "../templates/", dest)
return errors.New("Error message")
}
printErrorCallCount := 0
Expand Down
4 changes: 2 additions & 2 deletions src/compose-generator.go
Expand Up @@ -25,8 +25,8 @@ func main() {

// Main cli configuration
app := &cli.App{
Name: "compose-generator",
Version: util.BuildVersion(util.Version, util.Commit, util.Date, util.BuiltBy),
Name: "compose-generator",
Version: util.BuildVersion(util.Version, util.Commit, util.Date, util.BuiltBy),
Authors: []*cli.Author{
{
Name: "Marc Auberer",
Expand Down
1 change: 1 addition & 0 deletions src/model/cg-project.go
Expand Up @@ -26,6 +26,7 @@ type CGProject struct {
Ports []int
}

// Vars represents a list of environment variables
type Vars map[string]string

// CGProjectMetadata represents the metadata that is attached to a CGProject
Expand Down
2 changes: 1 addition & 1 deletion src/model/generate-config.go
Expand Up @@ -20,7 +20,7 @@ type ServiceConfig struct {
Params map[string]string `yaml:"params,omitempty"`
}

// GetServiceConfigurationsByName returns all specified service configurations by the name of their type
// GetServiceConfigurationsByType returns all specified service configurations by the name of their type
func (c GenerateConfig) GetServiceConfigurationsByType(templateType string) []ServiceConfig {
services := []ServiceConfig{}
for _, service := range c.ServiceConfig {
Expand Down
1 change: 1 addition & 0 deletions src/model/predefined-template.go
Expand Up @@ -63,6 +63,7 @@ func (t SelectedTemplates) GetTotal() int {
return count
}

// GetAllProxyQuestions returns all questions, which are marked as proxy questions
func (t SelectedTemplates) GetAllProxyQuestions() []Question {
questions := []Question{}
for _, template := range t.ProxyService {
Expand Down
2 changes: 2 additions & 0 deletions src/pass/generate/gen_add_profiles.go
Expand Up @@ -8,7 +8,9 @@ package pass
import "compose-generator/model"

const (
// ProfileDev is the name of the profile for development
ProfileDev = "dev"
// ProfileProduction is the name of the profile for production
ProfileProduction = "prod"
)

Expand Down
3 changes: 2 additions & 1 deletion src/pass/install/install_docker_darwin.go
@@ -1,9 +1,10 @@
// go:build darwin

/*
Copyright 漏 2021 Compose Generator Contributors
All rights reserved.
*/

// go:build darwin
package pass

import (
Expand Down
3 changes: 2 additions & 1 deletion src/pass/install/install_docker_linux.go
@@ -1,9 +1,10 @@
// go:build linux

/*
Copyright 漏 2021 Compose Generator Contributors
All rights reserved.
*/

// go:build linux
package pass

import (
Expand Down
3 changes: 2 additions & 1 deletion src/pass/install/install_docker_windows.go
@@ -1,9 +1,10 @@
// go:build windows

/*
Copyright 漏 2021 Compose Generator Contributors
All rights reserved.
*/

// go:build windows
package pass

import (
Expand Down
12 changes: 6 additions & 6 deletions src/util/cli.go
Expand Up @@ -139,11 +139,11 @@ func getToolboxImageVersion() string {
func getToolboxMountPath() string {
if isDockerizedEnvironment() { // Get the path which is mounted to /cg/out from outside the container
return getOuterVolumePathOnDockerizedEnvironmentMockable()
} else { // Get the current working directory
workingDir, err := getwd()
if err != nil {
printError("Could not find current working directory", err, true)
}
return workingDir
}
// Get the current working directory
workingDir, err := getwd()
if err != nil {
printError("Could not find current working directory", err, true)
}
return workingDir
}
2 changes: 1 addition & 1 deletion src/util/conditions.go
Expand Up @@ -31,7 +31,7 @@ func EvaluateConditionalSections(
}
}

// EvaluateConditionalSections evaluates conditional sections in template data
// EvaluateConditionalSectionsToString evaluates conditional sections in template data
func EvaluateConditionalSectionsToString(
input string,
selected *model.SelectedTemplates,
Expand Down
2 changes: 1 addition & 1 deletion src/util/env.go
Expand Up @@ -100,7 +100,7 @@ func IsToolboxPresent() bool {
return false
}

// IsDocker running checks if Docker is running
// IsDockerRunning checks if Docker is running
func IsDockerRunning() bool {
cmd := executeCommand("docker", "info")
output, err := getCommandOutput(cmd)
Expand Down
1 change: 1 addition & 0 deletions src/util/templates.go
Expand Up @@ -144,6 +144,7 @@ func AskTemplateQuestions(project *model.CGProject, template *model.PredefinedTe
}
}

// AskTemplateProxyQuestions aks the user all collected proxy questions for every selected service
func AskTemplateProxyQuestions(project *model.CGProject, template *model.PredefinedTemplateConfig, selectedTemplates *model.SelectedTemplates) {
// Ask proxy questions only if the service wants to get proxied
if template.Proxied {
Expand Down

0 comments on commit 4eb43e8

Please sign in to comment.