Compare commits

..

No commits in common. "master" and "v0.7.0" have entirely different histories.

12 changed files with 40 additions and 67 deletions

View File

@ -9,16 +9,13 @@ on:
jobs:
unittest:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go: [ stable ]
os: [ ubuntu-latest-amd64, ubuntu-latest-arm64 ]
runs-on:
- ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- uses: actions/setup-go@v5.5.0
with:
go-version: ${{ matrix.go }}
go-version: stable
- env:
GOPROXY: ${{ vars.GOPROXY }}
run: make test/unit

View File

@ -1,27 +0,0 @@
name: Golang CI lint
on:
pull_request:
types: [ "opened", "reopened", "synchronize" ]
push:
branches: [ '**' ]
tags-ignore: [ '**' ]
permissions:
contents: read
jobs:
golangci:
runs-on: ${{ matrix.os }}
strategy:
matrix:
go: [ stable ]
os: [ ubuntu-latest-amd64, ubuntu-latest-arm64 ]
steps:
- uses: actions/checkout@v4.2.2
- uses: actions/setup-go@v5.5.0
with:
go-version: ${{ matrix.go }}
- uses: golangci/golangci-lint-action@v8.0.0
with:
version: v2.1

View File

@ -1,18 +1,20 @@
name: 'Lint Markdown files'
name: Markdown linter
on:
pull_request:
types: [ "opened", "reopened", "synchronize" ]
push:
branches: [ '*' ]
tags-ignore: [ '*' ]
branches: [ '**' ]
tags-ignore: [ '**' ]
workflow_dispatch: {}
jobs:
markdown-lint:
container:
image: git.cryptic.systems/volker.raschek/markdownlint:0.45.0
runs-on:
- ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
- uses: DavidAnson/markdownlint-cli2-action@v20.0.0
with:
globs: '**/*.md'
- name: Lint Markdown files
run: markdownlint --config .markdownlint.yaml .

View File

@ -4,7 +4,6 @@ on:
push:
branches: [ 'master' ]
paths: [ 'README.md' ]
workflow_dispatch: {}
jobs:
update-description-on-hub-docker-io:

3
.gitignore vendored
View File

@ -1,3 +1,2 @@
dcmerge
coverage.txt
dist
coverage.txt

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"rewrap.wrappingColumn": 120,
}

View File

@ -20,6 +20,7 @@ DCMERGE_IMAGE_NAMESPACE?=${DCMERGE_IMAGE_REGISTRY_USER}
DCMERGE_IMAGE_NAME:=${EXECUTABLE}
DCMERGE_IMAGE_VERSION?=latest
DCMERGE_IMAGE_FULLY_QUALIFIED=${DCMERGE_IMAGE_REGISTRY_NAME}/${DCMERGE_IMAGE_NAMESPACE}/${DCMERGE_IMAGE_NAME}:${DCMERGE_IMAGE_VERSION}
DCMERGE_IMAGE_UNQUALIFIED=${DCMERGE_IMAGE_NAMESPACE}/${DCMERGE_IMAGE_NAME}:${DCMERGE_IMAGE_VERSION}
# BIN
# ==============================================================================
@ -92,13 +93,14 @@ container-image/build:
--no-cache \
--pull \
--tag ${DCMERGE_IMAGE_FULLY_QUALIFIED} \
--tag ${DCMERGE_IMAGE_UNQUALIFIED} \
.
# DELETE CONTAINER IMAGE
# ==============================================================================
PHONY:=container-image/delete
container-image/delete:
- ${CONTAINER_RUNTIME} image rm ${DCMERGE_IMAGE_FULLY_QUALIFIED}
- ${CONTAINER_RUNTIME} image rm ${DCMERGE_IMAGE_FULLY_QUALIFIED} ${DCMERGE_IMAGE_UNQUALIFIED}
# PUSH CONTAINER IMAGE
# ==============================================================================

View File

@ -19,18 +19,16 @@ func Execute(version string) error {
DisableFlagsInUseLine: true,
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
Args: cobra.MatchAll(cobra.ExactArgs(1)),
RunE: func(cmd *cobra.Command, args []string) error {
Run: func(cmd *cobra.Command, args []string) {
switch args[0] {
case "bash":
return cmd.Root().GenBashCompletion(os.Stdout)
cmd.Root().GenBashCompletion(os.Stdout)
case "zsh":
return cmd.Root().GenZshCompletion(os.Stdout)
cmd.Root().GenZshCompletion(os.Stdout)
case "fish":
return cmd.Root().GenFishCompletion(os.Stdout, true)
cmd.Root().GenFishCompletion(os.Stdout, true)
case "powershell":
return cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
default:
return fmt.Errorf("unknown shell: %v", args[0])
cmd.Root().GenPowerShellCompletionWithDesc(os.Stdout)
}
},
}
@ -55,17 +53,17 @@ dcmerge docker-compose.yml https://git.example.local/user/repo/docker-compose.ym
func run(cmd *cobra.Command, args []string) error {
mergeExisting, err := cmd.Flags().GetBool("existing-win")
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")
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")
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()
@ -78,7 +76,7 @@ func run(cmd *cobra.Command, args []string) error {
for _, config := range dockerComposeConfigs {
switch {
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:
dockerComposeConfig.MergeExistingWin(config)
case !mergeExisting && mergeLastWin:
@ -99,7 +97,7 @@ func run(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
defer func() { _ = f.Close() }()
defer f.Close()
yamlEncoder := yaml.NewEncoder(f)
yamlEncoder.SetIndent(2)

View File

@ -5,5 +5,5 @@ import "git.cryptic.systems/volker.raschek/dcmerge/cmd"
var version string
func main() {
_ = cmd.Execute(version)
cmd.Execute(version)
}

View File

@ -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.
func (sdoc *DependsOnContainer) MarshalYAML() (interface{}, error) {
var foundAnotherCondition = false
var dependencyNames = make([]string, 0)
var foundAnotherCondition bool = false
var dependencyNames []string
for dependencyName, dependencyDefinition := range sdoc.DependsOn {
if dependencyDefinition.Condition == ServiceDependsOnConditionServiceStarted {

View File

@ -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.
func ExistsInMap[T any](m map[string]T, name string) bool {
switch m {
case nil:
switch {
case m == nil:
return false
default:
_, present := m[name]

View File

@ -20,15 +20,15 @@ func Fetch(urls ...string) ([]*dockerCompose.Config, error) {
return nil, err
}
switch dockerComposeURL.Scheme {
case "http", "https":
switch {
case dockerComposeURL.Scheme == "http" || dockerComposeURL.Scheme == "https":
dockerComposeConfig, err := getDockerComposeViaHTTP(dockerComposeURL.String())
if err != nil {
return nil, err
}
dockerComposeConfigs = append(dockerComposeConfigs, dockerComposeConfig)
case "file":
case dockerComposeURL.Scheme == "file":
fallthrough
default:
dockerComposeConfig, err := readDockerComposeFromFile(dockerComposeURL.Path)
@ -43,7 +43,7 @@ func Fetch(urls ...string) ([]*dockerCompose.Config, error) {
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) {
req, err := http.NewRequest(http.MethodGet, url, nil)
@ -55,10 +55,10 @@ func getDockerComposeViaHTTP(url string) (*dockerCompose.Config, error) {
if err != nil {
return nil, err
}
defer func() { _ = resp.Body.Close() }()
defer resp.Body.Close()
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()
@ -85,7 +85,7 @@ func readDockerComposeFromFile(name string) (*dockerCompose.Config, error) {
if err != nil {
return nil, err
}
defer func() { _ = file.Close() }()
defer file.Close()
dockerCompose := dockerCompose.NewConfig()