chore(ci): be golangci-lint compatible
All checks were successful
Golang Tests / unittest (push) Successful in 28s
Markdown linter / markdown-lint (push) Successful in 3s
Golang CI lint / golangci (stable, ubuntu-latest-amd64) (push) Successful in 1m49s
Golang CI lint / golangci (stable, ubuntu-latest-arm64) (push) Successful in 2m13s
All checks were successful
Golang Tests / unittest (push) Successful in 28s
Markdown linter / markdown-lint (push) Successful in 3s
Golang CI lint / golangci (stable, ubuntu-latest-amd64) (push) Successful in 1m49s
Golang CI lint / golangci (stable, ubuntu-latest-arm64) (push) Successful in 2m13s
This commit is contained in:
parent
f8a7634e91
commit
9705b468fa
22
cmd/root.go
22
cmd/root.go
@ -19,16 +19,18 @@ func Execute(version string) error {
|
|||||||
DisableFlagsInUseLine: true,
|
DisableFlagsInUseLine: true,
|
||||||
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
|
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
|
||||||
Args: cobra.MatchAll(cobra.ExactArgs(1)),
|
Args: cobra.MatchAll(cobra.ExactArgs(1)),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
switch args[0] {
|
switch args[0] {
|
||||||
case "bash":
|
case "bash":
|
||||||
cmd.Root().GenBashCompletion(os.Stdout)
|
return cmd.Root().GenBashCompletion(os.Stdout)
|
||||||
case "zsh":
|
case "zsh":
|
||||||
cmd.Root().GenZshCompletion(os.Stdout)
|
return cmd.Root().GenZshCompletion(os.Stdout)
|
||||||
case "fish":
|
case "fish":
|
||||||
cmd.Root().GenFishCompletion(os.Stdout, true)
|
return cmd.Root().GenFishCompletion(os.Stdout, true)
|
||||||
case "powershell":
|
case "powershell":
|
||||||
cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
|
return cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unknown shell: %v", args[0])
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -53,17 +55,17 @@ dcmerge docker-compose.yml https://git.example.local/user/repo/docker-compose.ym
|
|||||||
func run(cmd *cobra.Command, args []string) error {
|
func run(cmd *cobra.Command, args []string) error {
|
||||||
mergeExisting, err := cmd.Flags().GetBool("existing-win")
|
mergeExisting, err := cmd.Flags().GetBool("existing-win")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to parse flag last-win: %s", err)
|
return fmt.Errorf("failed to parse flag last-win: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
mergeLastWin, err := cmd.Flags().GetBool("last-win")
|
mergeLastWin, err := cmd.Flags().GetBool("last-win")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to parse flag last-win: %s", err)
|
return fmt.Errorf("failed to parse flag last-win: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
outputFile, err := cmd.Flags().GetString("output-file")
|
outputFile, err := cmd.Flags().GetString("output-file")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to parse flag output-file: %s", err)
|
return fmt.Errorf("failed to parse flag output-file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
dockerComposeConfig := dockerCompose.NewConfig()
|
dockerComposeConfig := dockerCompose.NewConfig()
|
||||||
@ -76,7 +78,7 @@ func run(cmd *cobra.Command, args []string) error {
|
|||||||
for _, config := range dockerComposeConfigs {
|
for _, config := range dockerComposeConfigs {
|
||||||
switch {
|
switch {
|
||||||
case mergeExisting && mergeLastWin:
|
case mergeExisting && mergeLastWin:
|
||||||
return fmt.Errorf("Neither --first-win or --last-win can be specified - not booth.")
|
return fmt.Errorf("neither --first-win or --last-win can be specified - not booth")
|
||||||
case mergeExisting && !mergeLastWin:
|
case mergeExisting && !mergeLastWin:
|
||||||
dockerComposeConfig.MergeExistingWin(config)
|
dockerComposeConfig.MergeExistingWin(config)
|
||||||
case !mergeExisting && mergeLastWin:
|
case !mergeExisting && mergeLastWin:
|
||||||
@ -97,7 +99,7 @@ func run(cmd *cobra.Command, args []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer func() { _ = f.Close() }()
|
||||||
|
|
||||||
yamlEncoder := yaml.NewEncoder(f)
|
yamlEncoder := yaml.NewEncoder(f)
|
||||||
yamlEncoder.SetIndent(2)
|
yamlEncoder.SetIndent(2)
|
||||||
|
@ -1305,8 +1305,8 @@ func (sdoc *DependsOnContainer) Equal(equalable Equalable) bool {
|
|||||||
|
|
||||||
// MarshalYAML implements the MarshalYAML interface to customize the behavior when being marshaled into a YAML document.
|
// MarshalYAML implements the MarshalYAML interface to customize the behavior when being marshaled into a YAML document.
|
||||||
func (sdoc *DependsOnContainer) MarshalYAML() (interface{}, error) {
|
func (sdoc *DependsOnContainer) MarshalYAML() (interface{}, error) {
|
||||||
var foundAnotherCondition bool = false
|
var foundAnotherCondition = false
|
||||||
var dependencyNames []string
|
var dependencyNames = make([]string, 0)
|
||||||
|
|
||||||
for dependencyName, dependencyDefinition := range sdoc.DependsOn {
|
for dependencyName, dependencyDefinition := range sdoc.DependsOn {
|
||||||
if dependencyDefinition.Condition == ServiceDependsOnConditionServiceStarted {
|
if dependencyDefinition.Condition == ServiceDependsOnConditionServiceStarted {
|
||||||
|
@ -55,8 +55,8 @@ func EqualStringMap[R Equalable](mapA, mapB map[string]R) bool {
|
|||||||
|
|
||||||
// ExistsInMap returns true if object of type any exists under the passed name.
|
// ExistsInMap returns true if object of type any exists under the passed name.
|
||||||
func ExistsInMap[T any](m map[string]T, name string) bool {
|
func ExistsInMap[T any](m map[string]T, name string) bool {
|
||||||
switch {
|
switch m {
|
||||||
case m == nil:
|
case nil:
|
||||||
return false
|
return false
|
||||||
default:
|
default:
|
||||||
_, present := m[name]
|
_, present := m[name]
|
||||||
|
@ -20,15 +20,15 @@ func Fetch(urls ...string) ([]*dockerCompose.Config, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
switch dockerComposeURL.Scheme {
|
||||||
case dockerComposeURL.Scheme == "http" || dockerComposeURL.Scheme == "https":
|
case "http", "https":
|
||||||
dockerComposeConfig, err := getDockerComposeViaHTTP(dockerComposeURL.String())
|
dockerComposeConfig, err := getDockerComposeViaHTTP(dockerComposeURL.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
dockerComposeConfigs = append(dockerComposeConfigs, dockerComposeConfig)
|
dockerComposeConfigs = append(dockerComposeConfigs, dockerComposeConfig)
|
||||||
case dockerComposeURL.Scheme == "file":
|
case "file":
|
||||||
fallthrough
|
fallthrough
|
||||||
default:
|
default:
|
||||||
dockerComposeConfig, err := readDockerComposeFromFile(dockerComposeURL.Path)
|
dockerComposeConfig, err := readDockerComposeFromFile(dockerComposeURL.Path)
|
||||||
@ -43,7 +43,7 @@ func Fetch(urls ...string) ([]*dockerCompose.Config, error) {
|
|||||||
return dockerComposeConfigs, nil
|
return dockerComposeConfigs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var ErrorPathIsDir error = errors.New("Path is a directory")
|
var ErrorPathIsDir error = errors.New("path is a directory")
|
||||||
|
|
||||||
func getDockerComposeViaHTTP(url string) (*dockerCompose.Config, error) {
|
func getDockerComposeViaHTTP(url string) (*dockerCompose.Config, error) {
|
||||||
req, err := http.NewRequest(http.MethodGet, url, nil)
|
req, err := http.NewRequest(http.MethodGet, url, nil)
|
||||||
@ -55,10 +55,10 @@ func getDockerComposeViaHTTP(url string) (*dockerCompose.Config, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer func() { _ = resp.Body.Close() }()
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
return nil, fmt.Errorf("Received unexpected HTTP-Statuscode %v", resp.StatusCode)
|
return nil, fmt.Errorf("received unexpected HTTP-Statuscode %v", resp.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
dockerCompose := dockerCompose.NewConfig()
|
dockerCompose := dockerCompose.NewConfig()
|
||||||
@ -85,7 +85,7 @@ func readDockerComposeFromFile(name string) (*dockerCompose.Config, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer file.Close()
|
defer func() { _ = file.Close() }()
|
||||||
|
|
||||||
dockerCompose := dockerCompose.NewConfig()
|
dockerCompose := dockerCompose.NewConfig()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user