Skip to content

Commit

Permalink
refactor: make a clean open-source version
Browse files Browse the repository at this point in the history
  • Loading branch information
lazyfrosch committed Nov 17, 2023
0 parents commit 3dbdec1
Show file tree
Hide file tree
Showing 61 changed files with 4,788 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @Vitesco-Technologies/kubernetes
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
version: 2

updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: daily

- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
25 changes: 25 additions & 0 deletions .github/workflows/golang.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: golang

on:
push:
branches:
- main
pull_request:

jobs:
golang:
runs-on: [ubuntu-latest]

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod

- name: go test
run: go test -v ./...

- name: go build
run: go build .
22 changes: 22 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: golangci-lint

on:
push:
branches:
- main
pull_request:

jobs:
golangci-lint:
runs-on: [ubuntu-latest]

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
39 changes: 39 additions & 0 deletions .github/workflows/release.yml.disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: golang

# TODO: define new release method. Terraform Registry?
on:
push:
tags:
- v*

jobs:
golang:
runs-on: [self-hosted,cloudplatforms]
# TODO: github.com
# runs-on: [ubuntu-latest]

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod

# - name: Import GPG key
# uses: crazy-max/ghaction-import-gpg@v6
# id: import_gpg
# with:
# gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
# passphrase: ${{ secrets.GPG_PASSPHRASE }}

- name: Run goreleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --rm-dist
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59 changes: 59 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
terraform-provider-qip
terraform-provider-qip.exe
.env*

### Go ###
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
__debug*

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

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

### GoReleaser ###
/dist/

### Terraform ###
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log

# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
# .tfvars files are managed as part of configuration and so should be included in
# version control.
#
# example.tfvars

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# End of https://www.toptal.com/developers/gitignore/api/go,terraform

# Ignore CLI configuration files
.terraformrc
terraform.rc
terraform
.terraform*
99 changes: 99 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
---
# https://golangci-lint.run/usage/configuration/
run:
timeout: 5m

linters:
disable:
- noctx # Needs to be added later
- contextcheck # Needs to be added later
- exhaustivestruct
- exhaustruct
- varnamelen
- gochecknoinits
- gochecknoglobals

presets:
- bugs
- comment
# - complexity
- error
- format
- import
- metalinter
- module
- performance
- style
- test
- unused

linters-settings:
gci:
sections:
- standard
- default
- prefix(github.com/Vitesco-Technologies/terraform-provider-qip)
paralleltest:
ignore-missing: true
testpackage:
allow-packages:
- provider
- main
lll:
line-length: 140
depguard:
rules:
main:
files:
- "$all"
- "!$test"
- "!**/pkg/utils/**.go"
- "!**/pkg/qip/test/*.go"
allow:
- "$gostd"
- github.com/Vitesco-Technologies/terraform-provider-qip
- github.com/hashicorp/terraform-plugin-sdk/v2
- github.com/hashicorp/terraform-plugin-log/tflog
- github.com/hashicorp/go-cty/cty
deny:
- pkg: reflect
desc: Please don't use reflect package
utils:
files:
- "**/pkg/utils/**.go"
allow:
- "$gostd"
- github.com/iancoleman/orderedmap
deny:
- pkg: reflect
desc: Please don't use reflect package
test:
files:
- "$test"
- "**/pkg/qip/test/*.go"
allow:
- $gostd
- github.com/Vitesco-Technologies/terraform-provider-qip
- github.com/hashicorp/terraform-plugin-sdk/v2
- github.com/stretchr/testify
- github.com/jarcoal/httpmock
deny:
- pkg: reflect
desc: Please don't use reflect package
goheader:
template: |-
Copyright {{ YEAR }} Vitesco Technologies Group AG
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
46 changes: 46 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Visit https://goreleaser.com for documentation on how to customize this
# behavior.
builds:
- env:
- CGO_ENABLED=0
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
goos:
- windows
- linux
- darwin
goarch:
- amd64
- '386'
- arm64
ignore:
- goos: darwin
goarch: '386'
binary: '{{ .ProjectName }}_v{{ .Version }}'
archives:
- format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
checksum:
extra_files:
- glob: 'terraform-registry-manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256
# signs:
# - artifacts: checksum
# args:
# - "--batch"
# - "--local-user"
# - "{{ .Env.GPG_FINGERPRINT }}"
# - "--output"
# - "${signature}"
# - "--detach-sign"
# - "${artifact}"
# release:
# extra_files:
# - glob: 'signkey.asc'
# - glob: 'terraform-registry-manifest.json'
# name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude: ^docs/
- id: end-of-file-fixer
exclude: ^docs/
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/golangci/golangci-lint
rev: v1.54.2
hooks:
- id: golangci-lint

- repo: local
hooks:
- id: go-generate
name: go generate
language: system
entry: go generate ./...
pass_filenames: false
Loading

0 comments on commit 3dbdec1

Please sign in to comment.