Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/ci-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7

- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 12

- name: Run Golangci lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v9
with:
version: latest
args: --print-resources-usage
args: --verbose

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v6
with:
images: ${{ github.repository }},quay.io/${{ github.repository }}
labels: |
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/${{ github.repository }}/${{ github.event.repository.default_branch }}/README.md

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v4

- name: Build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v7
with:
context: .
file: ./Dockerfile
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release-assets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7

- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 12

- uses: actions/setup-go@v2
- uses: actions/setup-go@v6
with:
go-version: '1.19'
go-version: '1.26.5'
check-latest: true

- name: Build
run: |
make release-assets

- name: Upload assets to release
uses: svenstaro/upload-release-action@v2
uses: svenstaro/upload-release-action@2.11.5
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./release-assets/*
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/release-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7

- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 12

- name: Run Golangci lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v9
with:
version: latest
args: --print-resources-usage
args: --verbose

build:
needs: lint
Expand All @@ -35,7 +35,7 @@ jobs:
include: []
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7

- name: Set Swap Space
uses: pierotofy/set-swap-space@master
Expand All @@ -44,7 +44,7 @@ jobs:

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v6
with:
images: ${{ github.repository }},quay.io/${{ github.repository }}
labels: |
Expand All @@ -54,26 +54,26 @@ jobs:
suffix=${{ matrix.suffix }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v4

- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to Quay
uses: docker/login-action@v1
uses: docker/login-action@v4
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v7
with:
context: .
file: ./${{ matrix.Dockerfile }}
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/scheduled-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7

- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 12

- name: Run Golangci lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v9
with:
version: latest
args: --print-resources-usage
args: --verbose

build:
needs: lint
Expand All @@ -32,7 +32,7 @@ jobs:
include: []
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v7

- name: Set Swap Space
uses: pierotofy/set-swap-space@master
Expand All @@ -41,7 +41,7 @@ jobs:

- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v6
with:
images: ${{ github.repository }},quay.io/${{ github.repository }}
labels: |
Expand All @@ -51,26 +51,26 @@ jobs:
suffix=${{ matrix.suffix }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v4

- name: Login to DockerHub
uses: docker/login-action@v1
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Login to Quay
uses: docker/login-action@v1
uses: docker/login-action@v4
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v7
with:
context: .
file: ./${{ matrix.Dockerfile }}
Expand Down
46 changes: 28 additions & 18 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
run:
timeout: 120m

version: "2"
linters:
enable:
- asciicheck
- bidichk
- bodyclose
- copyloopvar
- errorlint
- exportloopref
- gosec
settings:
gosec:
confidence: low
config:
global:
audit: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
- gosec

linters-settings:
gosec:
excludes: []
confidence: low
config:
global:
audit: true

issues: {}

output:
sort-results: true
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#############################################
# Build
#############################################
FROM --platform=$BUILDPLATFORM golang:1.19-alpine as build
FROM --platform=$BUILDPLATFORM golang:1.26.5-alpine as build

Check warning on line 4 in Dockerfile

View workflow job for this annotation

GitHub Actions / build

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 4 in Dockerfile

View workflow job for this annotation

GitHub Actions / build (Dockerfile, auto)

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

RUN apk upgrade --no-cache --force
RUN apk add --update build-base make git
Expand All @@ -21,7 +21,7 @@
#############################################
# Test
#############################################
FROM gcr.io/distroless/static as test

Check warning on line 24 in Dockerfile

View workflow job for this annotation

GitHub Actions / build

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

Check warning on line 24 in Dockerfile

View workflow job for this annotation

GitHub Actions / build (Dockerfile, auto)

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/
USER 0:0
WORKDIR /app
COPY --from=build /go/src/github.com/webdevops/go-replace/go-replace .
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ cram-test: build

.PHONY: lint
lint: $(GOLANGCI_LINT_BIN)
time $(GOLANGCI_LINT_BIN) run --verbose --print-resources-usage
time $(GOLANGCI_LINT_BIN) run --verbose --verbose

$(GOLANGCI_LINT_BIN):
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(FIRST_GOPATH)/bin
Expand Down
2 changes: 1 addition & 1 deletion filehandling.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
// buffered reader.
func Readln(r *bufio.Reader) (string, error) {
var (
isPrefix bool = true
isPrefix = true
err error = nil
line, ln []byte
)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/webdevops/go-replace

go 1.19
go 1.26.5

require (
github.com/Masterminds/sprig v2.22.0+incompatible
Expand Down
2 changes: 1 addition & 1 deletion log.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func logError(err error) {

// Log error object as message
func logFatalErrorAndExit(err error, exitCode int) {
cmdline := fmt.Sprintf("%s %s", argparser.Command.Name, strings.Join(os.Args[1:], " "))
cmdline := fmt.Sprintf("%s %s", argparser.Name, strings.Join(os.Args[1:], " "))

fmt.Fprintf(os.Stderr, "Error: %s\n", err)
fmt.Fprintf(os.Stderr, "Command: %s\n", cmdline)
Expand Down
16 changes: 8 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ var pathFilterDirectories = []string{"autom4te.cache", "blib", "_build", ".bzr",
// Apply changesets to file
func applyChangesetsToFile(fileitem fileitem, changesets []changeset) (string, bool, error) {
var (
output string = ""
status bool = true
output = ""
status = true
)

// try open file
Expand Down Expand Up @@ -278,7 +278,7 @@ func handleSpecialCliOptions(args []string) {

// --output
if opts.Output != "" && len(args) > 1 {
logFatalErrorAndExit(errors.New("Only one file is allowed when using --output"), 1)
logFatalErrorAndExit(errors.New("only one file is allowed when using --output"), 1)
}

if opts.LineinfileBefore != "" || opts.LineinfileAfter != "" {
Expand All @@ -287,7 +287,7 @@ func handleSpecialCliOptions(args []string) {
}

if opts.LineinfileBefore != "" && opts.LineinfileAfter != "" {
logFatalErrorAndExit(errors.New("Only --lineinfile-after or --lineinfile-before is allowed in --mode=lineinfile"), 1)
logFatalErrorAndExit(errors.New("only --lineinfile-after or --lineinfile-before is allowed in --mode=lineinfile"), 1)
}
}
}
Expand Down Expand Up @@ -330,7 +330,7 @@ func actionProcessFiles(changesets []changeset, fileitems []fileitem) int {
os.Exit(0)
} else {
// no files found, print error and exit with error code
logFatalErrorAndExit(errors.New("No files specified"), 1)
logFatalErrorAndExit(errors.New("no files specified"), 1)
}
}

Expand Down Expand Up @@ -381,7 +381,7 @@ func actionProcessFiles(changesets []changeset, fileitems []fileitem) int {
}

if errorCount >= 1 {
fmt.Fprintf(os.Stderr, "[ERROR] %s failed with %d error(s)\n", argparser.Command.Name, errorCount)
fmt.Fprintf(os.Stderr, "[ERROR] %s failed with %d error(s)\n", argparser.Name, errorCount)
return 1
}

Expand All @@ -394,14 +394,14 @@ func buildChangesets() []changeset {
if !opts.ModeIsTemplate {
if len(opts.Search) == 0 || len(opts.Replace) == 0 {
// error: unequal numbers of search and replace options
logFatalErrorAndExit(errors.New("Missing either --search or --replace for this mode"), 1)
logFatalErrorAndExit(errors.New("missing either --search or --replace for this mode"), 1)
}
}

// check if search and replace options have equal lenght (equal number of options)
if len(opts.Search) != len(opts.Replace) {
// error: unequal numbers of search and replace options
logFatalErrorAndExit(errors.New("Unequal numbers of search or replace options"), 1)
logFatalErrorAndExit(errors.New("unequal numbers of search or replace options"), 1)
}

// build changesets
Expand Down