Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.
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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Ignore build and test binaries.
bin/
testbin/
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug
about: Create a bug report to help us improve
title: "[Bug] "
labels: bug
assignees: mmontes11

---

<!--
Bugs should be filed for issues encountered whilst operating mariadb-operator/init.
Please provide as much detail as possible.
-->

**Describe the bug**
<!--
A clear and concise description of what the bug is.
Tip: you can use
```
<code here>
```
for code blocks of your kubectl output or YAML files.
-->

**Expected behaviour**
<!--A concise description of what you expected to happen.-->

**Steps to reproduce the bug**
<!--Steps to reproduce the bug should be clear and easily reproducible to help people
gain an understanding of the problem.-->

**Additional context**
<!--Add any other context here.-->

**Environment details**:
- Kubernetes version:
- mariadb-operator version:
- init version:
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[Feature]"
labels: feature
assignees: mmontes11

---

**Is your feature request related to a problem? Please describe.**
<!--A clear and concise description of what the problem is-->

**Describe the solution you'd like**
<!--A clear and concise description of what you want to happen.-->

**Describe alternatives you've considered**
<!--A clear and concise description of any alternative solutions or features you've considered.-->

**Additional context**
<!--Add any other context here.-->

**Environment details**:
- Kubernetes version:
- mariadb-operator version:
- init version:
85 changes: 85 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: CI

on:
push:
branches:
- main
pull_request: {}

env:
GOLANGCI_VERSION: "v1.52.2"

jobs:
detect-noop:
runs-on: ubuntu-latest
outputs:
noop: ${{ steps.noop.outputs.should_skip }}
steps:
- name: Detect no-op changes
id: noop
uses: fkirc/skip-duplicate-actions@v5.3.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
paths_ignore: '["**.md"]'
concurrent_skipping: false

lint:
name: Lint
runs-on: ubuntu-latest
needs: detect-noop
if: ${{ needs.detect-noop.outputs.noop != 'true' }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version-file: "go.mod"
cache: true

- name: GolangCI Lint
uses: golangci/golangci-lint-action@v3
with:
version: ${{ env.GOLANGCI_VERSION }}

build:
name: Build
runs-on: ubuntu-latest
needs: detect-noop
if: ${{ needs.detect-noop.outputs.noop != 'true' }}
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version-file: "go.mod"
cache: true

- name: Build
run: make build

- name: Build Docker
run: make docker-build
env:
PLATFORM: linux/amd64

test:
name: Test
runs-on: ubuntu-latest
needs: detect-noop
if: ${{ needs.detect-noop.outputs.noop != 'true' }}
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version-file: "go.mod"
cache: true

- name: Test
run: make test
77 changes: 77 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Release

on:
push:
tags:
- "v*"

env:
GORELEASER_VERSION: "v1.18.2"

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Fetch tags
run: git fetch --force --tags

- name: Setup QEMU
uses: docker/setup-qemu-action@v2

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx

- name: Login to container Registry
uses: docker/login-action@v2
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io

- name: Prepare
id: prep
run: |
VERSION=sha-${GITHUB_SHA::8}
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF/refs\/tags\//}
fi
echo ::set-output name=BUILD_DATE::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo ::set-output name=VERSION::${VERSION}

- name: Publish multi-arch Docker image
uses: docker/build-push-action@v2
with:
push: true
builder: ${{ steps.buildx.outputs.name }}
context: .
file: ./Dockerfile
platforms: linux/arm64,linux/amd64
tags: |
ghcr.io/${{ github.repository_owner }}/init:${{ steps.prep.outputs.VERSION }}
ghcr.io/${{ github.repository_owner }}/init:latest
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version=${{ steps.prep.outputs.VERSION }}
org.opencontainers.image.created=${{ steps.prep.outputs.BUILD_DATE }}

- name: Set GORELEASER_PREVIOUS_TAG
run: echo "GORELEASER_PREVIOUS_TAG=$(git tag -l "v*" --sort=-version:refname | head -n 2 | tail -n 1)" >> $GITHUB_ENV

- name: GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
version: ${{ env.GORELEASER_VERSION }}
args: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
*.html

# Dependency directories (remove the comment below to include it)
vendor/

# Binaries
bin/

# Packaged Helm charts
*.tgz

# Directory to keep MariaDB files used for development
mariadb/
31 changes: 31 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
linters-settings:
gocyclo:
min-complexity: 20
lll:
line-length: 140
misspell:
locale: US

linters:
disable-all: true
enable:
- unused
- errcheck
- gocyclo
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- lll
- misspell
- nestif
- staticcheck
- typecheck
- unused
- bodyclose
- noctx

run:
timeout: 5m
go: "1.20"
14 changes: 14 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
changelog:
use: github-native
builds:
- id: init
main: main.go
binary: "init_{{ .Version }}_{{ .Arch }}"
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
- arm64
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "main.go"
}
]
}
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.20.4-alpine3.18 AS builder

ARG TARGETOS
ARG TARGETARCH
ENV CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH}

WORKDIR /app

COPY go.mod go.sum /app/
RUN go mod download

COPY . /app
RUN go build -o init main.go

FROM gcr.io/distroless/static AS app

WORKDIR /
COPY --from=builder /app/init /bin/init
USER 65532:65532

ENTRYPOINT ["/bin/init"]
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif

SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec

.PHONY: all
all: help

##@ General

.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

include make/deploy.mk
include make/dev.mk
include make/tooling.mk
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
# init
🍼 Init container for MariaDB that co-operates with mariadb-operator
<p align="center">
<img src="https://mariadb-operator.github.io/mariadb-operator/assets/mariadb-operator.png" alt="mariadb" width="250"/>
</p>

<p align="center">
<a href="https://github.com/mariadb-operator/init/actions/workflows/ci.yml"><img src="https://github.com/mariadb-operator/init/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
<a href="https://github.com/mariadb-operator/init/actions/workflows/release.yml"><img src="https://github.com/mariadb-operator/init/actions/workflows/release.yml/badge.svg" alt="Release"></a>
<a href="https://goreportcard.com/report/github.com/mariadb-operator/init"><img src="https://goreportcard.com/badge/github.com/mariadb-operator/init" alt="Go Report Card"></a>
<a href="https://pkg.go.dev/github.com/mariadb-operator/init"><img src="https://pkg.go.dev/badge/github.com/mariadb-operator/init.svg" alt="Go Reference"></a>
</p>

# 🍼 init
Init container for MariaDB that co-operates with [mariadb-operator](https://github.com/mariadb-operator/mariadb-operator).

🚧🚧🚧
Loading