You've already forked dcmerge
Compare commits
20 Commits
v0.7.0
...
ad8b5cca4e
Author | SHA1 | Date | |
---|---|---|---|
ad8b5cca4e
|
|||
027e7ed7ad
|
|||
b24b4e6a71
|
|||
c60eb969d0
|
|||
405f996e19
|
|||
f0a9073fa1 | |||
acaee3903c
|
|||
ed4609b326 | |||
a032247c59
|
|||
7ed6fee298
|
|||
9c256a53c4
|
|||
a5423dfe4d
|
|||
9705b468fa
|
|||
f8a7634e91
|
|||
96bdc09d14
|
|||
96447f88b3
|
|||
8635fd3334
|
|||
a6da12db45
|
|||
07067b6b47
|
|||
b50b9d8f19
|
29
.gitea/workflows/golang-linters.yaml
Normal file
29
.gitea/workflows/golang-linters.yaml
Normal file
@ -0,0 +1,29 @@
|
||||
name: "Lint Golang files"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [ "opened", "reopened", "synchronize" ]
|
||||
push:
|
||||
branches: [ '**' ]
|
||||
tags-ignore: [ '**' ]
|
||||
workflow_dispatch: {}
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
golangci:
|
||||
name: "Run golang CI linter"
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
go: [ stable ]
|
||||
os: [ ubuntu-latest-amd64, ubuntu-latest-arm64 ]
|
||||
steps:
|
||||
- uses: actions/checkout@v4.3.0
|
||||
- uses: actions/setup-go@v5.5.0
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
- uses: golangci/golangci-lint-action@v8.0.0
|
||||
with:
|
||||
v2.3.1 # renovate: datasource=github-releases depName=golangci/golangci-lint
|
@ -1,4 +1,4 @@
|
||||
name: Golang Tests
|
||||
name: "Run Golang tests"
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
@ -6,16 +6,37 @@ on:
|
||||
push:
|
||||
branches: [ '**' ]
|
||||
tags-ignore: [ '**' ]
|
||||
workflow_dispatch: {}
|
||||
|
||||
jobs:
|
||||
unittest:
|
||||
runs-on:
|
||||
- ubuntu-latest
|
||||
# integration-test:
|
||||
# name: "Run integration tests"
|
||||
# runs-on: ${{ matrix.os }}
|
||||
# strategy:
|
||||
# matrix:
|
||||
# go: [ stable ]
|
||||
# os: [ ubuntu-latest-amd64, ubuntu-latest-arm64 ]
|
||||
# steps:
|
||||
# - uses: actions/checkout@v4.3.0
|
||||
# - uses: actions/setup-go@v5.5.0
|
||||
# with:
|
||||
# go-version: ${{ matrix.go }}
|
||||
# - env:
|
||||
# GOPROXY: ${{ vars.GOPROXY }}
|
||||
# run: make test/integration
|
||||
|
||||
unit-test:
|
||||
name: "Run unit tests"
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
go: [ stable ]
|
||||
os: [ ubuntu-latest-amd64, ubuntu-latest-arm64 ]
|
||||
steps:
|
||||
- uses: actions/checkout@v4.2.2
|
||||
- uses: actions/checkout@v4.3.0
|
||||
- uses: actions/setup-go@v5.5.0
|
||||
with:
|
||||
go-version: stable
|
||||
go-version: ${{ matrix.go }}
|
||||
- env:
|
||||
GOPROXY: ${{ vars.GOPROXY }}
|
||||
run: make test/unit
|
||||
|
@ -1,20 +1,19 @@
|
||||
name: Markdown linter
|
||||
name: "Lint Markdown files"
|
||||
|
||||
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
|
||||
name: "Run markdown linter"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4.2.2
|
||||
- name: Lint Markdown files
|
||||
run: markdownlint --config .markdownlint.yaml .
|
||||
- uses: actions/checkout@v4.3.0
|
||||
- uses: DavidAnson/markdownlint-cli2-action@v20.0.0
|
||||
with:
|
||||
globs: '**/*.md'
|
||||
|
@ -1,4 +1,4 @@
|
||||
name: Release
|
||||
name: "Release"
|
||||
|
||||
on:
|
||||
push:
|
||||
@ -9,15 +9,15 @@ permissions:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on:
|
||||
- ubuntu-latest
|
||||
name: "Release application"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4.2.2
|
||||
- uses: actions/checkout@v4.3.0
|
||||
- uses: docker/setup-qemu-action@v3.6.0
|
||||
- uses: actions/setup-go@v5.5.0
|
||||
with:
|
||||
go-version: stable
|
||||
- uses: docker/login-action@v3.4.0
|
||||
- uses: docker/login-action@v3.5.0
|
||||
with:
|
||||
registry: git.cryptic.systems
|
||||
username: ${{ github.repository_owner }}
|
||||
@ -28,10 +28,11 @@ jobs:
|
||||
GOPROXY: ${{ vars.GOPROXY }}
|
||||
uses: goreleaser/goreleaser-action@v6.3.0
|
||||
with:
|
||||
version: "~> v2"
|
||||
version: v2.11.2 # renovate: datasource=github-releases depName=goreleaser/goreleaser
|
||||
args: release --clean
|
||||
|
||||
sync-to-hub-docker-io:
|
||||
name: "Upload Images to docker.io"
|
||||
needs:
|
||||
- release
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -1,16 +1,16 @@
|
||||
name: Update Docker Hub Description
|
||||
name: "Update Docker Hub Description"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ 'master' ]
|
||||
paths: [ 'README.md' ]
|
||||
workflow_dispatch: {}
|
||||
|
||||
jobs:
|
||||
update-description-on-hub-docker-io:
|
||||
runs-on:
|
||||
- ubuntu-latest
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4.2.2
|
||||
- uses: actions/checkout@v4.3.0
|
||||
- uses: peter-evans/dockerhub-description@v4.0.2
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_IO_USERNAME }}
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
dcmerge
|
||||
coverage.txt
|
||||
dist
|
13
.golangci.yaml
Normal file
13
.golangci.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
version: "2"
|
||||
linters:
|
||||
default: standard
|
||||
enable:
|
||||
- errname
|
||||
- gosec
|
||||
|
||||
exclusions:
|
||||
rules: []
|
||||
warn-unused: true
|
||||
|
||||
run:
|
||||
tests: true
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -1,3 +0,0 @@
|
||||
{
|
||||
"rewrap.wrappingColumn": 120,
|
||||
}
|
4
Makefile
4
Makefile
@ -20,7 +20,6 @@ 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
|
||||
# ==============================================================================
|
||||
@ -93,14 +92,13 @@ 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} ${DCMERGE_IMAGE_UNQUALIFIED}
|
||||
- ${CONTAINER_RUNTIME} image rm ${DCMERGE_IMAGE_FULLY_QUALIFIED}
|
||||
|
||||
# PUSH CONTAINER IMAGE
|
||||
# ==============================================================================
|
||||
|
24
cmd/root.go
24
cmd/root.go
@ -19,16 +19,18 @@ func Execute(version string) error {
|
||||
DisableFlagsInUseLine: true,
|
||||
ValidArgs: []string{"bash", "zsh", "fish", "powershell"},
|
||||
Args: cobra.MatchAll(cobra.ExactArgs(1)),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
switch args[0] {
|
||||
case "bash":
|
||||
cmd.Root().GenBashCompletion(os.Stdout)
|
||||
return cmd.Root().GenBashCompletion(os.Stdout)
|
||||
case "zsh":
|
||||
cmd.Root().GenZshCompletion(os.Stdout)
|
||||
return cmd.Root().GenZshCompletion(os.Stdout)
|
||||
case "fish":
|
||||
cmd.Root().GenFishCompletion(os.Stdout, true)
|
||||
return cmd.Root().GenFishCompletion(os.Stdout, true)
|
||||
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 {
|
||||
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()
|
||||
@ -76,7 +78,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:
|
||||
@ -88,16 +90,18 @@ func run(cmd *cobra.Command, args []string) error {
|
||||
|
||||
switch {
|
||||
case len(outputFile) > 0:
|
||||
// #nosec G301
|
||||
err = os.MkdirAll(filepath.Dir(outputFile), 0755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// #nosec G304
|
||||
f, err := os.Create(outputFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
defer func() { _ = f.Close() }()
|
||||
|
||||
yamlEncoder := yaml.NewEncoder(f)
|
||||
yamlEncoder.SetIndent(2)
|
||||
|
2
main.go
2
main.go
@ -5,5 +5,5 @@ import "git.cryptic.systems/volker.raschek/dcmerge/cmd"
|
||||
var version string
|
||||
|
||||
func main() {
|
||||
cmd.Execute(version)
|
||||
_ = cmd.Execute(version)
|
||||
}
|
||||
|
@ -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 bool = false
|
||||
var dependencyNames []string
|
||||
var foundAnotherCondition = false
|
||||
var dependencyNames = make([]string, 0)
|
||||
|
||||
for dependencyName, dependencyDefinition := range sdoc.DependsOn {
|
||||
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.
|
||||
func ExistsInMap[T any](m map[string]T, name string) bool {
|
||||
switch {
|
||||
case m == nil:
|
||||
switch m {
|
||||
case nil:
|
||||
return false
|
||||
default:
|
||||
_, present := m[name]
|
||||
|
@ -20,15 +20,15 @@ func Fetch(urls ...string) ([]*dockerCompose.Config, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
switch {
|
||||
case dockerComposeURL.Scheme == "http" || dockerComposeURL.Scheme == "https":
|
||||
switch dockerComposeURL.Scheme {
|
||||
case "http", "https":
|
||||
dockerComposeConfig, err := getDockerComposeViaHTTP(dockerComposeURL.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dockerComposeConfigs = append(dockerComposeConfigs, dockerComposeConfig)
|
||||
case dockerComposeURL.Scheme == "file":
|
||||
case "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 ErrPathIsDir 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 resp.Body.Close()
|
||||
defer func() { _ = 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()
|
||||
@ -78,14 +78,15 @@ func readDockerComposeFromFile(name string) (*dockerCompose.Config, error) {
|
||||
case err != nil:
|
||||
return nil, err
|
||||
case fileStat.IsDir():
|
||||
return nil, fmt.Errorf("%w: %s", ErrorPathIsDir, name)
|
||||
return nil, fmt.Errorf("%w: %s", ErrPathIsDir, name)
|
||||
}
|
||||
|
||||
// #nosec G304
|
||||
file, err := os.Open(name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer file.Close()
|
||||
defer func() { _ = file.Close() }()
|
||||
|
||||
dockerCompose := dockerCompose.NewConfig()
|
||||
|
||||
|
Reference in New Issue
Block a user