Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 14 additions & 0 deletions .bingo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

# Ignore everything
*

# But not these files:
!.gitignore
!*.mod
!*.sum
!README.md
!Variables.mk
!variables.env

*tmp.mod
*tmp.sum
13 changes: 13 additions & 0 deletions .bingo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Project Development Dependencies.

This is directory which stores Go modules with pinned buildable package that is used within this repository, managed by <https://github.com/bwplotka/bingo>.

* Run `bingo get` to install all tools having each own module file in this directory.
* Run `bingo get <tool>` to install `<tool>` that have own module file in this directory.
* For Makefile: Make sure to put `include .bingo/Variables.mk` in your Makefile, then use `\$(<UPPER_CASE_TOOL_NAME>)` variable where `<tool>` is the .bingo/`<tool>.mod`.
* For shell: Run `source .bingo/variables.env` to source all environment variable for each tool.
* See <https://github.com/bwplotka/bingo> or -h on how to add, remove or change binaries dependencies.

## Requirements

* Go 1.24.x or 1.25.x
31 changes: 31 additions & 0 deletions .bingo/Variables.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.10. DO NOT EDIT.
# All tools are designed to be build inside $GOBIN.
BINGO_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
GOPATH ?= $(shell go env GOPATH)
GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin
GO ?= $(shell which go)

# Ensure bingo-managed tools are always built for the host platform,
# even when GOOS/GOARCH are set for cross-compilation of other targets.
GOHOSTOS ?= $(shell $(GO) env GOHOSTOS)
GOHOSTARCH ?= $(shell $(GO) env GOHOSTARCH)
GOHOSTARM ?= $(shell $(GO) env GOHOSTARM)

# Below generated variables ensure that every time a tool under each variable is invoked, the correct version
# will be used; reinstalling only if needed.
# For example for golangci-lint variable:
#
# In your main Makefile (for non array binaries):
#
#include .bingo/Variables.mk # Assuming -dir was set to .bingo .
#
#command: $(GOLANGCI_LINT)
# @echo "Running golangci-lint"
# @$(GOLANGCI_LINT) <flags/args..>
#
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v2.1.6
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
@echo "(re)installing $(GOBIN)/golangci-lint-v2.1.6"
@cd $(BINGO_DIR) && GOWORK=off GOOS=$(GOHOSTOS) GOARCH=$(GOHOSTARCH) GOARM=$(GOHOSTARM) $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v2.1.6 "github.com/golangci/golangci-lint/v2/cmd/golangci-lint"

1 change: 1 addition & 0 deletions .bingo/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module _ // Fake go.mod auto-created by 'bingo' for go -moddir compatibility with non-Go projects. Commit this file, together with other .mod files.
5 changes: 5 additions & 0 deletions .bingo/golangci-lint.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT

go 1.25.7

require github.com/golangci/golangci-lint/v2 v2.1.6 // cmd/golangci-lint
952 changes: 952 additions & 0 deletions .bingo/golangci-lint.sum

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions .bingo/variables.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.10. DO NOT EDIT.
# All tools are designed to be build inside $GOBIN.
# Those variables will work only until 'bingo get' was invoked, or if tools were installed via Makefile's Variables.mk.
GOBIN=${GOBIN:=$(go env GOBIN)}

if [ -z "$GOBIN" ]; then
GOBIN="$(go env GOPATH)/bin"
fi


GOLANGCI_LINT="${GOBIN}/golangci-lint-v2.1.6"

68 changes: 68 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Build artifacts
bin/
*.exe
*.dll
*.so
*.dylib

# IDE and editor files
.idea/
.vscode/
*.swp
*.swo
*~
.DS_Store

# Git
.git/
.gitignore
.github/

# Environment files
.env
.env.*

# Local config files
*.local.yaml

# CI/CD files (not needed in container)
.gitlab-ci.yml
.travis.yml
Jenkinsfile

# Kubernetes and deployment files
chart/
charts/
deployments/

# License and owners
LICENSE
OWNERS
CONTRIBUTING.md

# Temporary files
tmp/
temp/
*.tmp

# Log files
*.log

# Test and coverage files
coverage/
*.out
*.test
*.prof

# Linter config (not needed for build)
.golangci.yml

# AI assistant config
.claude/

# Dockerfile itself
Dockerfile

# Documentation (not needed in container)
*.md
docs/
49 changes: 49 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Binaries
bin/
*.exe
*.exe~
*.dll
*.so
*.dylib

# Build artifacts
build/
*.o
*.a

# Test coverage
coverage.txt
coverage.html
coverage.out
*.coverprofile
*.test

# Go workspace
go.work
go.work.sum

# IDE
.idea/
.vscode/
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db

# Environment files
.env
.env.local
*.local

# Dependency directories (if vendoring)
vendor/

# Node.js (if any legacy files exist)
node_modules/
package-lock.json

# temporary
tmp/
99 changes: 99 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# HyperFleet Standard golangci-lint Configuration
# Reference: https://golangci-lint.run/usage/configuration
#
# This is the baseline configuration for all HyperFleet Go repositories.
# See: https://github.com/openshift-hyperfleet/architecture/blob/main/hyperfleet/standards/linting.md

version: "2"

run:
timeout: 5m
tests: true
modules-download-mode: readonly

linters:
enable:
# Code Quality
- errcheck
- govet
- staticcheck
- ineffassign
- unused
- unconvert
- unparam
- goconst
- exhaustive

# Code Style
- misspell
- lll
- revive
- gocritic

# Security
- gosec
settings:
errcheck:
check-type-assertions: true
check-blank: true
govet:
enable-all: true
goconst:
min-len: 3
min-occurrences: 3
misspell:
locale: US
lll:
line-length: 120
revive:
rules:
- name: exported
severity: warning
disabled: true
- name: unexported-return
severity: warning
disabled: false
- name: var-naming
severity: warning
disabled: false
unparam:
check-exported: false
exhaustive:
default-signifies-exhaustive: true
exclusions:
generated: lax
rules:
# Relaxed rules for test files
- linters:
- gosec
- errcheck
- unparam
path: _test\.go
paths:
- third_party(/|$)
- builtin(/|$)
- examples(/|$)

issues:
max-issues-per-linter: 0
max-same-issues: 0
new: false

formatters:
enable:
- gofmt
- goimports
settings:
gofmt:
simplify: true
exclusions:
generated: lax
paths:
- third_party(/|$)
- builtin(/|$)
- examples(/|$)

output:
formats:
text:
path: stdout
6 changes: 6 additions & 0 deletions .hyperfleet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# .hyperfleet.yaml - Repository metadata for HyperFleet tooling
version: v1
repository:
types: [service]
name: hyperfleet-hooks
description: Shared validation tools and pre-commit hooks for HyperFleet projects
14 changes: 14 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
# HyperFleet pre-commit hooks registry
# https://pre-commit.com/

- id: hyperfleet-commitlint
name: Validate commit message (HyperFleet Standard)
description: >
Validates commit messages against the HyperFleet Commit Standard
(Conventional Commits with optional JIRA prefix).
entry: hyperfleet-hooks commitlint
language: golang
stages: [commit-msg]
pass_filenames: true
always_run: true
53 changes: 53 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
ARG BASE_IMAGE=registry.access.redhat.com/ubi9-micro:latest

FROM registry.access.redhat.com/ubi9/go-toolset:1.25 AS builder

ARG GIT_SHA=unknown
ARG GIT_DIRTY=""
ARG BUILD_DATE=""
ARG APP_VERSION="0.0.0-dev"

USER root
RUN dnf install -y make && dnf clean all
WORKDIR /build
RUN chown 1001:0 /build
USER 1001

ENV GOBIN=/build/.gobin
RUN mkdir -p $GOBIN

COPY --chown=1001:0 go.mod go.sum ./
RUN --mount=type=cache,target=/opt/app-root/src/go/pkg/mod,uid=1001 \
go mod download

COPY --chown=1001:0 . .

# CGO_ENABLED=0 produces a static binary. The default ubi-minimal runtime
# supports both static and dynamically linked binaries.
# For FIPS-compliant builds, use CGO_ENABLED=1 + GOEXPERIMENT=boringcrypto.
RUN --mount=type=cache,target=/opt/app-root/src/go/pkg/mod,uid=1001 \
--mount=type=cache,target=/opt/app-root/src/.cache/go-build,uid=1001 \
CGO_ENABLED=0 GOOS=linux \
GIT_SHA=${GIT_SHA} GIT_DIRTY=${GIT_DIRTY} BUILD_DATE=${BUILD_DATE} APP_VERSION=${APP_VERSION} \
make build

# Runtime stage
FROM ${BASE_IMAGE}

WORKDIR /app

# ubi9-micro doesn't include CA certificates; copy from builder for TLS (e.g. GitHub API)
COPY --from=builder /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
COPY --from=builder /build/bin/hyperfleet-hooks /app/hyperfleet-hooks

USER 65532:65532

ENTRYPOINT ["/app/hyperfleet-hooks"]
CMD ["--help"]

ARG APP_VERSION="0.0.0-dev"
LABEL name="hyperfleet-hooks" \
vendor="Red Hat" \
version="${APP_VERSION}" \
summary="HyperFleet Hooks - Commit Message Validator" \
description="Validates commit messages against HyperFleet standards"
Loading