22 Commits

Author SHA1 Message Date
84b6615bda chore(deps): update module github.com/spf13/cobra to v1.10.1
Some checks failed
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (push) Successful in 1m52s
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (push) Successful in 54s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (pull_request) Successful in 50s
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (pull_request) Successful in 39s
Lint Markdown files / Run markdown linter (pull_request) Successful in 16s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (push) Has been cancelled
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (push) Has been cancelled
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (pull_request) Has been cancelled
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (pull_request) Has been cancelled
2025-09-01 19:06:15 +00:00
c551806f56 Merge pull request 'chore(deps): update goreleaser/goreleaser-action action to v6.4.0' (#9) from renovate/actions into master
All checks were successful
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (push) Successful in 6s
Lint Markdown files / Run markdown linter (push) Successful in 4s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (push) Successful in 49s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (push) Successful in 30s
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (push) Successful in 20s
2025-08-14 16:10:44 +00:00
ff32c63ec0 chore(deps): update goreleaser/goreleaser-action action to v6.4.0
All checks were successful
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (push) Successful in 9s
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (push) Successful in 6s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (pull_request) Successful in 8s
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (pull_request) Successful in 5s
Lint Markdown files / Run markdown linter (pull_request) Successful in 4s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (push) Successful in 27s
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (push) Successful in 19s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (pull_request) Successful in 27s
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (pull_request) Successful in 20s
2025-08-14 16:04:39 +00:00
3d4e5d0e15 Merge pull request 'chore(deps): update dependency golangci/golangci-lint to v2.4.0' (#8) from renovate/golangci-golangci-lint-2.x into master
All checks were successful
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (push) Successful in 7s
Lint Markdown files / Run markdown linter (push) Successful in 4s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (push) Successful in 1m38s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (push) Successful in 28s
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (push) Successful in 19s
2025-08-14 01:21:19 +00:00
742a00d91d chore(deps): update dependency golangci/golangci-lint to v2.4.0
All checks were successful
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (push) Successful in 26s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (pull_request) Successful in 8s
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (pull_request) Successful in 13s
Lint Markdown files / Run markdown linter (pull_request) Successful in 4s
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (push) Successful in 1m42s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (push) Successful in 1m28s
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (push) Successful in 49s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (pull_request) Successful in 30s
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (pull_request) Successful in 21s
2025-08-14 01:05:32 +00:00
7425cfe2d0 Merge pull request 'chore(deps): update dependency golangci/golangci-lint to v2.3.1' (#7) from renovate/golangci-golangci-lint-2.x into master
All checks were successful
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (push) Successful in 12s
Lint Markdown files / Run markdown linter (push) Successful in 4s
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (push) Successful in 36s
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (push) Successful in 20s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (push) Successful in 41s
2025-08-12 16:20:37 +00:00
ccd0d62503 chore(deps): update dependency golangci/golangci-lint to v2.3.1
All checks were successful
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (push) Successful in 12s
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (push) Successful in 6s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (pull_request) Successful in 11s
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (pull_request) Successful in 5s
Lint Markdown files / Run markdown linter (pull_request) Successful in 3s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (push) Successful in 41s
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (push) Successful in 22s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (pull_request) Successful in 41s
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (pull_request) Successful in 20s
2025-08-12 13:03:42 +00:00
0bfc39536d Merge pull request 'chore(deps): update docker/login-action action to v3.5.0' (#5) from renovate/actions into master
All checks were successful
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (push) Successful in 12s
Lint Markdown files / Run markdown linter (push) Successful in 4s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (push) Successful in 39s
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (push) Successful in 39s
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (push) Successful in 19s
2025-08-12 12:15:06 +00:00
32bc80cc49 chore(deps): update actions/checkout action to v4.3.0
All checks were successful
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (push) Successful in 11s
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (push) Successful in 5s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (pull_request) Successful in 12s
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (pull_request) Successful in 5s
Lint Markdown files / Run markdown linter (pull_request) Successful in 4s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (push) Successful in 41s
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (push) Successful in 18s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (pull_request) Successful in 40s
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (pull_request) Successful in 21s
2025-08-12 12:10:55 +00:00
b0c90c4cb3 fix(lint): be compliant with golangci-lint
All checks were successful
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (push) Successful in 20s
Lint Markdown files / Run markdown linter (push) Successful in 3s
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (push) Successful in 35s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (push) Successful in 1m3s
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (push) Successful in 19s
2025-08-12 13:53:32 +02:00
b4dcb26b45 fix(ci): rename workflows; add golang ci lint
Some checks failed
Lint Markdown files / Run markdown linter (push) Successful in 4s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-amd64) (push) Failing after 15s
Run Golang tests / Run unit tests (stable, ubuntu-latest-amd64) (push) Successful in 27s
Lint Golang files / Run golang CI linter (stable, ubuntu-latest-arm64) (push) Failing after 57s
Run Golang tests / Run unit tests (stable, ubuntu-latest-arm64) (push) Successful in 17s
2025-08-12 09:25:53 +02:00
794c779667 chore(ci): add golangci-lint
Some checks failed
Golang Tests / unittest (stable, ubuntu-latest-amd64) (push) Successful in 22s
Golang CI lint / golangci (stable, ubuntu-latest-amd64) (push) Failing after 17s
Lint Markdown files / markdown-lint (push) Successful in 4s
Golang Tests / unittest (stable, ubuntu-latest-arm64) (push) Successful in 2m15s
Golang CI lint / golangci (stable, ubuntu-latest-arm64) (push) Failing after 1m29s
2025-06-01 12:18:42 +02:00
3f93bd2dec chore(ci): update workflow_dispatch for update docker hub description
All checks were successful
Golang Tests / unittest (push) Successful in 17s
Lint Markdown files / markdown-lint (push) Successful in 15s
2025-05-31 22:06:32 +02:00
45a41e3ba4 docs(README): remove obsolete line
All checks were successful
Lint Markdown files / markdown-lint (push) Successful in 16s
Golang Tests / unittest (push) Successful in 20s
Update Docker Hub Description / update-description-on-hub-docker-io (push) Successful in 11s
2025-05-31 17:57:19 +02:00
b40e00ba5b chore(ci): adapt release workflow
Some checks failed
Lint Markdown files / markdown-lint (push) Successful in 12s
Golang Tests / unittest (push) Has been cancelled
2025-05-31 17:56:14 +02:00
be5691762c chore(ci): adapt release workflow
Some checks failed
Lint Markdown files / markdown-lint (push) Successful in 16s
Golang Tests / unittest (push) Successful in 20s
Update Docker Hub Description / update-description-on-hub-docker-io (push) Failing after 11s
2025-05-31 17:52:49 +02:00
a28437ec0e chore(ci): adapt release workflow
Some checks failed
Lint Markdown files / markdown-lint (push) Successful in 18s
Golang Tests / unittest (push) Has been cancelled
2025-05-31 17:51:41 +02:00
23da9d9aea feat: use goreleaser 2025-05-31 17:50:38 +02:00
4e23b5f299 feat(goreleaser): init 2025-05-29 13:25:29 +02:00
27e89bc54a chore(ci): remove travis 2025-03-31 17:00:01 +02:00
37c783df37 chore(renovate): use configuration preset 2025-03-31 16:59:38 +02:00
7a285f13a9 fix: remove github workflows 2024-04-08 13:24:19 +02:00
27 changed files with 647 additions and 459 deletions

View File

@ -1 +1 @@
bin
app

View File

@ -1,12 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = false
trim_trailing_whitespace = true
[Makefile]
[{Makefile,*.go}]
indent_style = tab

1
.gitattributes vendored
View File

@ -1 +0,0 @@
Makefile eol=lf

View 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:
version: v2.4.0 # renovate: datasource=github-releases depName=golangci/golangci-lint

View File

@ -0,0 +1,42 @@
name: "Run Golang tests"
on:
pull_request:
types: [ "opened", "reopened", "synchronize" ]
push:
branches: [ '**' ]
tags-ignore: [ '**' ]
workflow_dispatch: {}
jobs:
# 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.3.0
- uses: actions/setup-go@v5.5.0
with:
go-version: ${{ matrix.go }}
- env:
GOPROXY: ${{ vars.GOPROXY }}
run: make test/unit

View File

@ -0,0 +1,19 @@
name: "Lint Markdown files"
on:
pull_request:
types: [ "opened", "reopened", "synchronize" ]
push:
branches: [ '*' ]
tags-ignore: [ '*' ]
workflow_dispatch: {}
jobs:
markdown-lint:
name: "Run markdown linter"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.3.0
- uses: DavidAnson/markdownlint-cli2-action@v20.0.0
with:
globs: '**/*.md'

View File

@ -0,0 +1,52 @@
name: "Release"
on:
push:
tags: [ '**' ]
permissions:
contents: write
jobs:
release:
name: "Release application"
runs-on: ubuntu-latest
steps:
- 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.5.0
with:
registry: git.cryptic.systems
username: ${{ github.repository_owner }}
password: ${{ secrets.GIT_CRYPTIC_SYSTEMS_PACKAGE_REGISTRY_TOKEN }}
- env:
GITEA_TOKEN: ${{ secrets.GIT_CRYPTIC_SYSTEMS_PACKAGE_REGISTRY_TOKEN }}
GONOSUMDB: ${{ vars.GONOSUMDB }}
GOPROXY: ${{ vars.GOPROXY }}
uses: goreleaser/goreleaser-action@v6.4.0
with:
version: v2.11.2 # renovate: datasource=github-releases depName=goreleaser/goreleaser
args: release --clean
sync-to-hub-docker-io:
needs:
- release
runs-on: ubuntu-latest
steps:
- name: Copy images to docker.io
run: |
TAG=$(echo ${{ github.ref_name }} | sed 's/v//gm')
apt-get update --yes
apt-get install --yes skopeo
skopeo copy \
--all \
--dest-password ${{ secrets.DOCKER_IO_PASSWORD }} \
--dest-username ${{ secrets.DOCKER_IO_USERNAME }} \
--src-password ${{ secrets.GIT_CRYPTIC_SYSTEMS_PACKAGE_REGISTRY_TOKEN }} \
--src-username volker.raschek \
docker://git.cryptic.systems/volker.raschek/docker-hub-description-updater:${TAG} \
docker://docker.io/volkerraschek/dhcu:${TAG}

View File

@ -0,0 +1,20 @@
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
steps:
- uses: actions/checkout@v4.3.0
- uses: peter-evans/dockerhub-description@v4.0.2
with:
username: ${{ secrets.DOCKER_IO_USERNAME }}
password: ${{ secrets.DOCKER_IO_PASSWORD }}
repository: volkerraschek/dhdu
readme-filepath: README.md

View File

@ -1,35 +0,0 @@
version: 2
updates:
# Maintain dependencies for docker
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
assignees:
- "volker-raschek"
labels:
- "dependabot"
- "dependabot/docker"
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
assignees:
- "volker-raschek"
labels:
- "dependabot"
- "dependabot/github-actions"
# Maintain dependencies for golang
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
assignees:
- "volker-raschek"
labels:
- "dependabot"
- "dependabot/gomod"

View File

@ -1,19 +0,0 @@
name: auto-merge
on:
pull_request:
jobs:
auto-merge:
permissions:
actions: read
checks: read
contents: write
statuses: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ahmadnassri/action-dependabot-auto-merge@v2
with:
target: minor
github-token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,41 +0,0 @@
name: build-latest
on:
push:
branches:
- master
pull_request:
types: [ opened, reopened ]
env:
CONTAINER_RUNTIME: docker
jobs:
cancel:
runs-on:
- ubuntu-22.04
steps:
- name: cancel previous runs
uses: styfle/cancel-workflow-action@0.9.1
with:
all_but_latest: true
access_token: ${{ github.token }}
build-amd64-latest:
runs-on:
- ubuntu-22.04
needs:
- cancel
steps:
- name: clone
uses: actions/checkout@v2
- name: update apt cache
run: sudo apt update --yes
- name: upgrade packages
run: sudo apt upgrade --yes
- name: install build-essential
run: sudo apt install --yes build-essential
- name: set up docker
uses: docker-practice/actions-setup-docker@master
- name: build
run: make container-image/build/amd64

7
.gitignore vendored
View File

@ -1,4 +1,3 @@
/bin
/dhd
**/bindata*.go
docker-hub-description-updater
coverage.txt
dist

13
.golangci.yaml Normal file
View File

@ -0,0 +1,13 @@
version: "2"
linters:
default: standard
enable:
- errname
- gosec
exclusions:
rules: []
warn-unused: true
run:
tests: true

175
.goreleaser.yaml Normal file
View File

@ -0,0 +1,175 @@
project_name: docker-hub-description-updater
archives:
- formats: [ "tar.xz" ]
files:
- README.md
- LICENSE
before:
hooks:
- go mod tidy
builds:
- main: main.go
binary: >-
{{ .ProjectName }}-
{{- .Version }}-
{{- .Os }}-
{{- if eq .Arch "amd64" }}amd64
{{- else if eq .Arch "amd64_v1" }}amd64
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}-{{ .Arm }}{{ end }}
env:
- CGO_ENABLED=0
- GONOSUMDB={{ .Env.GONOSUMDB }}
- GOPROXY={{ .Env.GOPROXY }}
goos:
- linux
goarch:
- amd64
- arm
- arm64
- riscv64
goarm:
- "6"
- "7"
flags:
- -trimpath
ldflags:
- -s -w -X 'main.version={{ trimprefix .Tag "v" }}'
changelog:
filters:
exclude:
- '^chore'
- '^docs'
- '^test'
- Merge pull request
- Merge branch
- go mod tidy
format: "{{.SHA}}: {{.Message}} (@{{.AuthorUsername}})"
groups:
- title: Features
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
order: 0
- title: "Bug fixes"
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
order: 1
- title: Others
order: 999
sort: asc
use: git
dockers:
- build_flag_templates:
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.documentation={{ .ProjectName }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.source={{ .GitURL }}
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }}
- --platform=linux/amd64
- --pull
dockerfile: Dockerfile
goarch: amd64
goos: linux
image_templates:
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-amd64'
skip_push: false
use: buildx
- build_flag_templates:
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.documentation={{ .ProjectName }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.source={{ .GitURL }}
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }}
- --platform=linux/arm/v6
- --pull
dockerfile: Dockerfile
goarch: arm
goarm: "6"
goos: linux
image_templates:
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm-v6'
skip_push: false
use: buildx
- build_flag_templates:
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.documentation={{ .ProjectName }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.source={{ .GitURL }}
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }}
- --platform=linux/arm/v7
- --pull
dockerfile: Dockerfile
goarch: arm
goarm: "7"
goos: linux
image_templates:
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm-v7'
skip_push: false
use: buildx
- build_flag_templates:
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.documentation={{ .ProjectName }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.source={{ .GitURL }}
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }}
- --platform=linux/arm64
- --pull
dockerfile: Dockerfile
goarch: arm64
goos: linux
image_templates:
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm64'
skip_push: false
use: buildx
- build_flag_templates:
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.documentation={{ .ProjectName }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.source={{ .GitURL }}
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://git.cryptic.systems/volker.raschek/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ trimprefix .Tag "v" }}
- --platform=linux/riscv64
- --pull
dockerfile: Dockerfile
goarch: riscv64
goos: linux
image_templates:
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-riscv64'
skip_push: false
use: buildx
docker_manifests:
- name_template: 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}'
image_templates:
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-amd64'
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm-v6'
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm-v7'
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-arm64'
- 'git.cryptic.systems/volker.raschek/{{ .ProjectName }}:{{ trimprefix .Tag "v" }}-riscv64'
gitea_urls:
api: https://git.cryptic.systems/api/v1
download: https://git.cryptic.systems
version: 2

136
.markdownlint.yaml Normal file
View File

@ -0,0 +1,136 @@
# markdownlint YAML configuration
# https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
# Default state for all rules
default: true
# Path to configuration file to extend
extends: null
# MD003/heading-style/header-style - Heading style
MD003:
# Heading style
style: "atx"
# MD004/ul-style - Unordered list style
MD004:
style: "dash"
# MD007/ul-indent - Unordered list indentation
MD007:
# Spaces for indent
indent: 2
# Whether to indent the first level of the list
start_indented: false
# MD009/no-trailing-spaces - Trailing spaces
MD009:
# Spaces for line break
br_spaces: 2
# Allow spaces for empty lines in list items
list_item_empty_lines: false
# Include unnecessary breaks
strict: false
# MD010/no-hard-tabs - Hard tabs
MD010:
# Include code blocks
code_blocks: true
# MD012/no-multiple-blanks - Multiple consecutive blank lines
MD012:
# Consecutive blank lines
maximum: 1
# MD013/line-length - Line length
MD013:
# Number of characters
line_length: 120
# Number of characters for headings
heading_line_length: 120
# Number of characters for code blocks
code_block_line_length: 120
# Include code blocks
code_blocks: false
# Include tables
tables: false
# Include headings
headings: true
# Strict length checking
strict: false
# Stern length checking
stern: false
# MD022/blanks-around-headings/blanks-around-headers - Headings should be surrounded by blank lines
MD022:
# Blank lines above heading
lines_above: 1
# Blank lines below heading
lines_below: 1
# MD025/single-title/single-h1 - Multiple top-level headings in the same document
MD025:
# Heading level
level: 1
# RegExp for matching title in front matter
front_matter_title: "^\\s*title\\s*[:=]"
# MD026/no-trailing-punctuation - Trailing punctuation in heading
MD026:
# Punctuation characters
punctuation: ".,;:!。,;:!"
# MD029/ol-prefix - Ordered list item prefix
MD029:
# List style
style: "one_or_ordered"
# MD030/list-marker-space - Spaces after list markers
MD030:
# Spaces for single-line unordered list items
ul_single: 1
# Spaces for single-line ordered list items
ol_single: 1
# Spaces for multi-line unordered list items
ul_multi: 1
# Spaces for multi-line ordered list items
ol_multi: 1
# MD033/no-inline-html - Inline HTML
MD033:
# Allowed elements
allowed_elements: []
# MD035/hr-style - Horizontal rule style
MD035:
# Horizontal rule style
style: "---"
# MD036/no-emphasis-as-heading/no-emphasis-as-header - Emphasis used instead of a heading
MD036:
# Punctuation characters
punctuation: ".,;:!?。,;:!?"
# MD041/first-line-heading/first-line-h1 - First line in a file should be a top-level heading
MD041:
# Heading level
level: 1
# RegExp for matching title in front matter
front_matter_title: "^\\s*title\\s*[:=]"
# MD044/proper-names - Proper names should have the correct capitalization
MD044:
# List of proper names
names: []
# Include code blocks
code_blocks: false
# MD046/code-block-style - Code block style
MD046:
# Block style
style: "fenced"
# MD048/code-fence-style - Code fence style
MD048:
# Code fence syle
style: "backtick"

View File

@ -1,35 +0,0 @@
services:
- docker
stages:
- build
# - test
- deploy
jobs:
include:
- name: build-linux-amd64
stage: build
script: make container-run/bin/linux/amd64/dhdu
- name: build-linux-arm5
stage: build
script: make container-run/bin/linux/arm/5/dhdu
- name: build-linux-arm7
stage: build
script: make container-run/bin/linux/arm/7/dhdu
# - name: test-linux-amd64
# stage: test
# script: make container-run/test/unit
# after_script: bash <(curl -s https://codecov.io/bash)
- name: deploy-container-amd64
stage: deploy
script: make container-image/push/amd64
notifications:
email:
on_success: change
on_failure: change

View File

@ -1,23 +1,5 @@
# ARGs
# ==================================
ARG BASE_IMAGE
ARG BUILD_IMAGE
ARG EXECUTABLE_TARGET
ARG GOPROXY
ARG GOPRIVATE
ARG VERSION
FROM scratch AS build
# BUILD
# ==============================================================================
FROM ${BUILD_IMAGE} AS build-env
COPY docker-hub-description-updater-* /usr/bin/docker-hub-description-updater
ADD ./ /workspace
RUN make clean ${EXECUTABLE_TARGET} GOPROXY=${GOPROXY}
# TARGET
# ==============================================================================
FROM ${BASE_IMAGE}
COPY --from=build-env /workspace/${EXECUTABLE_TARGET} /usr/bin/dhdu
RUN chmod +x /usr/bin/dhdu
ENTRYPOINT [ "/usr/bin/dhdu" ]
ENTRYPOINT [ "/usr/bin/docker-hub-description-updater" ]

251
Makefile
View File

@ -1,195 +1,114 @@
# VERSION
# If no version is specified as a parameter of make, the last git hash
# value is taken.
# VERSION?=$(shell git describe --abbrev=0)+hash.$(shell git rev-parse --short HEAD)
VERSION?=0.0.0+hash.$(shell git rev-parse --short HEAD)
EXECUTABLE=docker-hub-description-updater
VERSION?=$(shell git describe --abbrev=0)+hash.$(shell git rev-parse --short HEAD)
# EXECUTABLE
# Executable binary which should be compiled for different architecures
EXECUTABLE:=dhdu
# LINUX_EXECUTABLES AND TARGETS
LINUX_EXECUTABLES:=\
linux/amd64/${EXECUTABLE} \
linux/arm/5/${EXECUTABLE} \
linux/arm/7/${EXECUTABLE}
LINUX_EXECUTABLE_TARGETS:=${LINUX_EXECUTABLES:%=bin/%}
# UNIX_EXECUTABLES AND TARGETS
# Define all executables for different architectures and operation systems
UNIX_EXECUTABLES:=\
${LINUX_EXECUTABLES}
UNIX_EXECUTABLE_TARGETS:=\
${LINUX_EXECUTABLE_TARGETS}
# EXECUTABLE_TARGETS
# Include all UNIX and Windows targets.
EXECUTABLES:=\
${UNIX_EXECUTABLES}
EXECUTABLE_TARGETS:=\
${UNIX_EXECUTABLE_TARGETS}
# Destination directory and prefix to place the compiled binaries, documentaions
# and other files.
DESTDIR?=
PREFIX?=/usr/local
# CONTAINER_RUNTIME
# The CONTAINER_RUNTIME variable will be used to specified the path to a
# container runtime. This is needed to start and run a container images.
CONTAINER_RUNTIME?=$(shell which docker)
# container runtime. This is needed to start and run a container image.
CONTAINER_RUNTIME?=$(shell which podman)
# BUILD_IMAGE
# Definition of the container build image, in which the Binary are compiled from
# source code
BUILD_IMAGE_REGISTRY:=docker.io
BUILD_IMAGE_NAMESPACE:=volkerraschek
BUILD_IMAGE_NAME:=build-image
BUILD_IMAGE_VERSION:=latest
BUILD_IMAGE_FULL=${BUILD_IMAGE_REGISTRY}/${BUILD_IMAGE_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_IMAGE_VERSION:v%=%}
BUILD_IMAGE_SHORT=${BUILD_IMAGE_NAMESPACE}/${BUILD_IMAGE_NAME}:${BUILD_IMAGE_VERSION:v%=%}
# DOCKERHUB_DESCRIPTION_UPDATER_IMAGE_REGISTRY_NAME
# Defines the name of the new container to be built using several variables.
DOCKERHUB_DESCRIPTION_UPDATER_IMAGE_REGISTRY_NAME:=git.cryptic.systems
DOCKERHUB_DESCRIPTION_UPDATER_IMAGE_REGISTRY_USER:=volker.raschek
# BASE_IMAGE
# Definition of the base container image
BASE_IMAGE_REGISTRY:=docker.io
BASE_IMAGE_NAMESPACE:=library
BASE_IMAGE_NAME:=alpine
BASE_IMAGE_VERSION:=3.11.2
BASE_IMAGE_FULL=${BASE_IMAGE_REGISTRY}/${BASE_IMAGE_NAMESPACE}/${BASE_IMAGE_NAME}:${BASE_IMAGE_VERSION:v%=%}
BASE_IMAGE_SHORT=${BASE_IMAGE_NAMESPACE}/${BASE_IMAGE_NAME}:${BASE_IMAGE_VERSION:v%=%}
DOCKERHUB_DESCRIPTION_UPDATER_IMAGE_NAMESPACE?=${DOCKERHUB_DESCRIPTION_UPDATER_IMAGE_REGISTRY_USER}
DOCKERHUB_DESCRIPTION_UPDATER_IMAGE_NAME:=${EXECUTABLE}
DOCKERHUB_DESCRIPTION_UPDATER_IMAGE_VERSION?=latest
DOCKERHUB_DESCRIPTION_UPDATER_IMAGE_FULLY_QUALIFIED=${DOCKERHUB_DESCRIPTION_UPDATER_IMAGE_REGISTRY_NAME}/${DOCKERHUB_DESCRIPTION_UPDATER_IMAGE_NAMESPACE}/${DOCKERHUB_DESCRIPTION_UPDATER_IMAGE_NAME}:${DOCKERHUB_DESCRIPTION_UPDATER_IMAGE_VERSION}
# CONTAINER_IMAGE
# Definition of the container image
CONTAINER_IMAGE_REGISTRY:=docker.io
CONTAINER_IMAGE_NAMESPACE:=volkerraschek
CONTAINER_IMAGE_NAME:=${EXECUTABLE}
CONTAINER_IMAGE_VERSION:=latest
CONTAINER_IMAGE_FULL=${CONTAINER_IMAGE_REGISTRY}/${CONTAINER_IMAGE_NAMESPACE}/${CONTAINER_IMAGE_NAME}:${CONTAINER_IMAGE_VERSION:v%=%}
CONTAINER_IMAGE_SHORT=${CONTAINER_IMAGE_NAMESPACE}/${CONTAINER_IMAGE_NAME}:${CONTAINER_IMAGE_VERSION:v%=%}
README_FILE:=README.md
# BINARIES
# BIN
# ==============================================================================
PHONY:=all
${EXECUTABLE}: bin/tmp/${EXECUTABLE}
all: ${EXECUTABLE_TARGETS}
bin/linux/amd64/${EXECUTABLE}: bindata
docker-hub-description-updater:
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64 \
GOPROXY=${GOPROXY} \
GOPRIVATE=${GOPRIVATE} \
go build -ldflags "-X main.version=${VERSION}" -o ${@}
bin/linux/arm/5/${EXECUTABLE}: bindata
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=arm \
GOARM=5 \
GOPROXY=${GOPROXY} \
GOPRIVATE=${GOPRIVATE} \
go build -ldflags "-X main.version=${VERSION}" -o ${@}
bin/linux/arm/7/${EXECUTABLE}: bindata
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=arm \
GOARM=5 \
GOPROXY=${GOPROXY} \
GOPRIVATE=${GOPRIVATE} \
go build -ldflags "-X main.version=${VERSION}" -o ${@}
bin/tmp/${EXECUTABLE}: bindata
GOPROXY=${GOPROXY} \
GOPRIVATE=${GOPRIVATE} \
go build -ldflags "-X main.version=${VERSION}" -o ${@}
# BINDATA
# ==============================================================================
BINDATA_TARGETS := \
pkg/hub/bindata.go
PHONY+=bindata
bindata: ${BINDATA_TARGETS}
pkg/hub/bindata.go:
go-bindata -pkg hub -o ${@} README.md
# TEST
# ==============================================================================
PHONY+=test
test: clean bin/tmp/${EXECUTABLE}
REGISTRY_USER=${REGISTRY_USER} \
REGISTRY_PASSWORD=${REGISTRY_PASSWORD} \
REGISTRY_NAMESPACE=${REGISTRY_NAMESPACE} \
CONTAINER_IMAGE_NAME=${CONTAINER_IMAGE_NAME} \
README_FILE=${README_FILE} \
go test -v ./pkg/...
GOPROXY=$(shell go env GOPROXY) \
go build -ldflags "-X 'main.version=${VERSION}'" -o ${@} main.go
# CLEAN
# ==============================================================================
PHONY+=clean
clean:
rm --force ${EXECUTABLE} || true
rm --force --recursive bin || true
rm --force --recursive ${BINDATA_TARGETS} || true
rm --force --recursive docker-hub-description-updater
# CONTAINER IMAGE STEPS
# TESTS
# ==============================================================================
PHONY+=container-image/build/amd64
container-image/build/amd64:
PHONY+=test/unit
test/unit:
CGO_ENABLED=0 \
GOPROXY=$(shell go env GOPROXY) \
go test -v -p 1 -coverprofile=coverage.txt -covermode=count -timeout 1200s ./pkg/...
PHONY+=test/integration
test/integration:
CGO_ENABLED=0 \
GOPROXY=$(shell go env GOPROXY) \
go test -v -p 1 -count=1 -timeout 1200s ./it/...
PHONY+=test/coverage
test/coverage: test/unit
CGO_ENABLED=0 \
GOPROXY=$(shell go env GOPROXY) \
go tool cover -html=coverage.txt
# GOLANGCI-LINT
# ==============================================================================
PHONY+=golangci-lint
golangci-lint:
golangci-lint run --concurrency=$(shell nproc)
# INSTALL
# ==============================================================================
PHONY+=uninstall
install: docker-hub-description-updater
install --directory ${DESTDIR}/etc/bash_completion.d
./docker-hub-description-updater completion bash > ${DESTDIR}/etc/bash_completion.d/${EXECUTABLE}
install --directory ${DESTDIR}${PREFIX}/bin
install --mode 0755 ${EXECUTABLE} ${DESTDIR}${PREFIX}/bin/${EXECUTABLE}
install --directory ${DESTDIR}${PREFIX}/share/licenses/${EXECUTABLE}
install --mode 0644 LICENSE ${DESTDIR}${PREFIX}/share/licenses/${EXECUTABLE}/LICENSE
# UNINSTALL
# ==============================================================================
PHONY+=uninstall
uninstall:
-rm --force --recursive \
${DESTDIR}/etc/bash_completion.d/${EXECUTABLE} \
${DESTDIR}${PREFIX}/bin/${EXECUTABLE} \
${DESTDIR}${PREFIX}/share/licenses/${EXECUTABLE}
# BUILD CONTAINER IMAGE
# ==============================================================================
PHONY+=container-image/build
container-image/build:
${CONTAINER_RUNTIME} build \
--build-arg BASE_IMAGE=${BASE_IMAGE_FULL} \
--build-arg BUILD_IMAGE=${BUILD_IMAGE_FULL} \
--build-arg EXECUTABLE=${EXECUTABLE} \
--build-arg EXECUTABLE_TARGET=bin/linux/amd64/${EXECUTABLE} \
--build-arg GOPROXY \
--build-arg GOPRIVATE \
--build-arg VERSION=${VERSION} \
--file Dockerfile \
--no-cache \
--tag ${CONTAINER_IMAGE_FULL} \
--tag ${CONTAINER_IMAGE_SHORT} \
--pull \
--tag ${DOCKERHUB_DESCRIPTION_UPDATER_IMAGE_FULLY_QUALIFIED} \
.
PHONY+=container-image/push/amd64
container-image/push/amd64: container-image/build/amd64
${CONTAINER_RUNTIME} login ${CONTAINER_IMAGE_REGISTRY} \
--username ${CONTAINER_IMAGE_REGISTRY_USER} \
--password ${CONTAINER_IMAGE_REGISTRY_PASSWORD}
${CONTAINER_RUNTIME} push ${CONTAINER_IMAGE_FULL}
# CONTAINER STEPS - BINARY
# DELETE CONTAINER IMAGE
# ==============================================================================
PHONY+=container-run/all
container-run/all:
$(MAKE) container-run COMMAND=${@:container-run/%=%}
PHONY:=container-image/delete
container-image/delete:
- ${CONTAINER_RUNTIME} image rm ${DOCKERHUB_DESCRIPTION_UPDATER_IMAGE_FULLY_QUALIFIED}
PHONY+=${UNIX_EXECUTABLE_TARGETS:%=container-run/%}
${UNIX_EXECUTABLE_TARGETS:%=container-run/%}:
$(MAKE) container-run COMMAND=${@:container-run/%=%}
# CONTAINER STEPS - CLEAN
# PUSH CONTAINER IMAGE
# ==============================================================================
PHONY+=container-run/clean
container-run/clean:
$(MAKE) container-run COMMAND=${@:container-run/%=%}
# GENERAL CONTAINER COMMAND
# ==============================================================================
PHONY+=container-run
container-run:
${CONTAINER_RUNTIME} run \
--rm \
--volume ${PWD}:/workspace \
${BUILD_IMAGE_FULL} \
make ${COMMAND} \
VERSION=${VERSION} \
GOPROXY=${GOPROXY} \
GOPRIVATE=${GOPRIVATE} \
PHONY+=container-image/push
container-image/push:
echo ${DOCKERHUB_DESCRIPTION_UPDATER_IMAGE_REGISTRY_PASSWORD} | ${CONTAINER_RUNTIME} login ${DOCKERHUB_DESCRIPTION_UPDATER_IMAGE_REGISTRY_NAME} --username ${DOCKERHUB_DESCRIPTION_UPDATER_IMAGE_REGISTRY_USER} --password-stdin
${CONTAINER_RUNTIME} push ${DOCKERHUB_DESCRIPTION_UPDATER_IMAGE_FULLY_QUALIFIED}
# PHONY
# ==============================================================================
# Declare the contents of the PHONY variable as phony. We keep that information
# in a variable so we can use it in if_changed.
.PHONY: ${PHONY}

View File

@ -1,8 +1,5 @@
# docker hub description updater
[![Build Status](https://travis-ci.com/volker-raschek/docker-hub-description-updater.svg?branch=master)](https://travis-ci.com/volker-raschek/docker-hub-description-updater)
[![Go Report Card](https://goreportcard.com/badge/github.com/volker-raschek/docker-hub-description-updater)](https://goreportcard.com/report/github.com/volker-raschek/docker-hub-description-updater)
[![GoDoc Reference](https://godoc.org/github.com/volker-raschek/docker-hub-description-updater?status.svg)](http://godoc.org/github.com/volker-raschek/docker-hub-description-updater)
[![Docker Pulls](https://img.shields.io/docker/pulls/volkerraschek/dhdu)](https://hub.docker.com/r/volkerraschek/dhdu)
By specifying the login data for [hub.docker.com](https://hub.docker.com) you
@ -10,8 +7,6 @@ can update the short and long description of a docker repository.
## Usage
Test
The examples below describe two ways to update the full description of the
docker hub repository. First by the binary and second by a container based way.

View File

@ -2,7 +2,6 @@ package cmd
import (
"fmt"
"io/ioutil"
"log"
"os"
@ -19,7 +18,7 @@ var (
)
// Execute a
func Execute(version string) {
func Execute(version string) error {
rootCmd := &cobra.Command{
Use: "dhdu",
Short: "docker hub description updater (dhdu)",
@ -31,7 +30,7 @@ func Execute(version string) {
rootCmd.Flags().StringVarP(&dockerHubPassword, "password", "p", "", "Docker Hub Password")
rootCmd.Flags().StringVarP(&dockerHubRepository, "repository", "r", "", "Docker Hub Repository")
rootCmd.Flags().StringVarP(&dockerHubUser, "username", "u", "", "Docker Hub Username")
rootCmd.Execute()
return rootCmd.Execute()
}
func runE(cmd *cobra.Command, args []string) error {
@ -39,29 +38,30 @@ func runE(cmd *cobra.Command, args []string) error {
file := args[0]
if len(dockerHubUser) <= 0 {
return fmt.Errorf("No user defined over flags")
return fmt.Errorf("no user defined over flags")
}
if len(dockerHubPassword) <= 0 {
return fmt.Errorf("No password defined over flags")
return fmt.Errorf("no password defined over flags")
}
if len(dockerHubNamespace) <= 0 {
log.Printf("No namespace defined over flags: Use docker username %v instead", dockerHubUser)
log.Printf("no namespace defined over flags: Use docker username %v instead", dockerHubUser)
dockerHubNamespace = dockerHubUser
}
if len(dockerHubRepository) <= 0 {
return fmt.Errorf("No repository defined over flags")
return fmt.Errorf("nNo repository defined over flags")
}
if _, err := os.Stat(file); os.IsNotExist(err) && len(file) <= 0 {
return fmt.Errorf("Can not find file: %v", file)
return fmt.Errorf("can not find file: %v", file)
}
f, err := ioutil.ReadFile(file)
// #nosec G304
f, err := os.ReadFile(file)
if err != nil {
return fmt.Errorf("Can not read file %v: %v", file, err)
return fmt.Errorf("can not read file %v: %v", file, err)
}
fullDescription := string(f)

16
go.mod
View File

@ -1,16 +1,10 @@
module github.com/volker-raschek/docker-hub-description-updater
go 1.18
go 1.24
require github.com/spf13/cobra v1.10.1
require (
github.com/spf13/cobra v0.0.3
github.com/stretchr/testify v1.4.0
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
gopkg.in/yaml.v2 v2.2.2 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/pflag v1.0.9 // indirect
)

26
go.sum
View File

@ -1,18 +1,10 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.3.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s=
github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.1 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

View File

@ -9,5 +9,5 @@ var (
)
func main() {
cmd.Execute(version)
_ = cmd.Execute(version)
}

View File

@ -3,13 +3,11 @@ package hub
import "errors"
var (
errorFailedToCreateRequest = errors.New("Failed to create http request")
errorFailedToParseJSON = errors.New("Failed to parse json")
errorFailedToParseURL = errors.New("Failed to parse url")
errorFailedToSendRequest = errors.New("Failed to send http request")
errorNoUserDefined = errors.New("No User defined")
errorNoPasswordDefined = errors.New("No Password defined")
errorNoNamespaceDefined = errors.New("No Namespace defined")
errorNoRepositoryDefined = errors.New("No Repository defined")
errorUnexpectedHTTPStatuscode = errors.New("Unexpected HTTP-Statuscode")
errFailedToCreateRequest = errors.New("failed to create http request")
errFailedToParseJSON = errors.New("failed to parse json")
errFailedToParseURL = errors.New("failed to parse url")
errFailedToSendRequest = errors.New("failed to send http request")
errNoNamespaceDefined = errors.New("no Namespace defined")
errNoRepositoryDefined = errors.New("no Repository defined")
errUnexpectedHTTPStatuscode = errors.New("unexpected HTTP-Statuscode")
)

View File

@ -25,22 +25,22 @@ type Hub struct {
func (h *Hub) GetRepository(namespace string, name string) (*types.Repository, error) {
if len(namespace) <= 0 {
return nil, errorNoNamespaceDefined
return nil, errNoNamespaceDefined
}
if len(name) <= 0 {
return nil, errorNoRepositoryDefined
return nil, errNoRepositoryDefined
}
rawURL := fmt.Sprintf("%v/repositories/%v/%v", dockerHubAPI, namespace, name)
url, err := url.Parse(rawURL)
if err != nil {
return nil, fmt.Errorf("%v: %v", errorFailedToParseURL, err)
return nil, fmt.Errorf("%v: %v", errFailedToParseURL, err)
}
req, err := http.NewRequest(http.MethodGet, url.String(), nil)
if err != nil {
return nil, fmt.Errorf("%v: %v", errorFailedToCreateRequest, err)
return nil, fmt.Errorf("%v: %v", errFailedToCreateRequest, err)
}
if h.token == nil {
@ -54,18 +54,18 @@ func (h *Hub) GetRepository(namespace string, name string) (*types.Repository, e
resp, err := h.client.Do(req)
if err != nil {
return nil, fmt.Errorf("%v: %v", errorFailedToSendRequest, err)
return nil, fmt.Errorf("%v: %v", errFailedToSendRequest, err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("%v: expect %v, received %v", errorUnexpectedHTTPStatuscode, http.StatusOK, resp.StatusCode)
return nil, fmt.Errorf("%v: expect %v, received %v", errUnexpectedHTTPStatuscode, http.StatusOK, resp.StatusCode)
}
repository := new(types.Repository)
jsonDecoder := json.NewDecoder(resp.Body)
if err := jsonDecoder.Decode(repository); err != nil {
return nil, fmt.Errorf("%v: %v", errorFailedToParseJSON, err)
return nil, fmt.Errorf("%v: %v", errFailedToParseJSON, err)
}
return repository, nil
@ -75,30 +75,30 @@ func (h *Hub) getToken() (*types.Token, error) {
loginBuffer := new(bytes.Buffer)
jsonEncoder := json.NewEncoder(loginBuffer)
if err := jsonEncoder.Encode(h.credentials); err != nil {
return nil, fmt.Errorf("%v: %v", errorFailedToParseJSON, err)
return nil, fmt.Errorf("%v: %v", errFailedToParseJSON, err)
}
rawURL := fmt.Sprintf("%v/users/login/", dockerHubAPI)
req, err := http.NewRequest(http.MethodPost, rawURL, loginBuffer)
if err != nil {
return nil, fmt.Errorf("%v: %v", errorFailedToCreateRequest, err)
return nil, fmt.Errorf("%v: %v", errFailedToCreateRequest, err)
}
req.Header.Add("Content-Type", "application/json")
resp, err := h.client.Do(req)
if err != nil {
return nil, fmt.Errorf("%v: %v", errorFailedToCreateRequest, err)
return nil, fmt.Errorf("%v: %v", errFailedToCreateRequest, err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("%v: expect %v, received %v", errorUnexpectedHTTPStatuscode, http.StatusOK, resp.StatusCode)
return nil, fmt.Errorf("%v: expect %v, received %v", errUnexpectedHTTPStatuscode, http.StatusOK, resp.StatusCode)
}
token := new(types.Token)
jsonDecoder := json.NewDecoder(resp.Body)
if err := jsonDecoder.Decode(token); err != nil {
return nil, fmt.Errorf("%v: %v", errorFailedToParseJSON, err)
return nil, fmt.Errorf("%v: %v", errFailedToParseJSON, err)
}
return token, nil
@ -108,11 +108,11 @@ func (h *Hub) getToken() (*types.Token, error) {
func (h *Hub) PatchRepository(repository *types.Repository) (*types.Repository, error) {
if len(repository.Namespcace) <= 0 {
return nil, errorNoNamespaceDefined
return nil, errNoNamespaceDefined
}
if len(repository.Name) <= 0 {
return nil, errorNoRepositoryDefined
return nil, errNoRepositoryDefined
}
if h.token == nil {
@ -127,7 +127,7 @@ func (h *Hub) PatchRepository(repository *types.Repository) (*types.Repository,
rawURL := fmt.Sprintf("%v/repositories/%v/%v", dockerHubAPI, repository.Namespcace, repository.Name)
patchURL, err := url.Parse(rawURL)
if err != nil {
return nil, fmt.Errorf("%v: %v", errorFailedToParseURL, err)
return nil, fmt.Errorf("%v: %v", errFailedToParseURL, err)
}
data := &url.Values{}
@ -136,24 +136,24 @@ func (h *Hub) PatchRepository(repository *types.Repository) (*types.Repository,
req, err := http.NewRequest(http.MethodPatch, patchURL.String(), nil)
if err != nil {
return nil, fmt.Errorf("%v: %v", errorFailedToCreateRequest, err)
return nil, fmt.Errorf("%v: %v", errFailedToCreateRequest, err)
}
req.Header.Set("Authorization", fmt.Sprintf("JWT %v", h.token.Token))
resp, err := h.client.Do(req)
if err != nil {
return nil, fmt.Errorf("%v: %v", errorFailedToCreateRequest, err)
return nil, fmt.Errorf("%v: %v", errFailedToCreateRequest, err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("%v: expect %v, received %v", errorUnexpectedHTTPStatuscode, http.StatusOK, resp.StatusCode)
return nil, fmt.Errorf("%v: expect %v, received %v", errUnexpectedHTTPStatuscode, http.StatusOK, resp.StatusCode)
}
patchedRepository := new(types.Repository)
jsonDecoder := json.NewDecoder(resp.Body)
if err := jsonDecoder.Decode(h.token); err != nil {
return nil, fmt.Errorf("%v: %v", errorFailedToParseJSON, err)
return nil, fmt.Errorf("%v: %v", errFailedToParseJSON, err)
}
return patchedRepository, nil

View File

@ -1,54 +0,0 @@
package hub
import (
"os"
"testing"
"github.com/stretchr/testify/require"
"github.com/volker-raschek/docker-hub-description-updater/pkg/types"
)
func TestPatchRepository(t *testing.T) {
dockerHubUser := os.Getenv("REGISTRY_USER")
if len(dockerHubUser) <= 0 {
t.Fatalf("Environment variable REGISTRY_USER is empty")
}
dockerHubPassword := os.Getenv("REGISTRY_PASSWORD")
if len(dockerHubPassword) <= 0 {
t.Fatalf("Environment variable REGISTRY_PASSWORD is empty")
}
dockerHubNamespace := os.Getenv("REGISTRY_NAMESPACE")
if len(dockerHubNamespace) <= 0 {
t.Fatalf("Environment variable REGISTRY_NAMESPACE is empty")
}
dockerHubRepository := os.Getenv("CONTAINER_IMAGE_NAME")
if len(dockerHubRepository) <= 0 {
t.Fatalf("Environment variable CONTAINER_IMAGE_NAME is empty")
}
loginCredentials := &types.LoginCredentials{
User: dockerHubUser,
Password: dockerHubPassword,
}
h := New(loginCredentials)
require := require.New(t)
readme, err := Asset("README.md")
require.NoError(err)
currentRepository, err := h.GetRepository(dockerHubNamespace, dockerHubRepository)
require.NoError(err)
expectedRepository := *currentRepository
expectedRepository.FullDescription = string(readme)
actualRepository, err := h.PatchRepository(&expectedRepository)
require.NoError(err)
require.EqualValues(&expectedRepository.FullDescription, actualRepository.FullDescription, "Full description not equal")
}

View File

@ -1,3 +1,10 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"local>volker.raschek/renovate-config:default#master",
"local>volker.raschek/renovate-config:container#master",
"local>volker.raschek/renovate-config:actions#master",
"local>volker.raschek/renovate-config:golang#master",
"local>volker.raschek/renovate-config:regexp#master"
]
}