Skip to content

Commit

Permalink
chore: apply pre-commit rules
Browse files Browse the repository at this point in the history
  • Loading branch information
arxeiss committed Jun 24, 2024
1 parent 50f0214 commit eb985f0
Show file tree
Hide file tree
Showing 12 changed files with 154 additions and 142 deletions.
75 changes: 38 additions & 37 deletions .github/workflows/build-image-for-jarvis.yaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
---
name: Image build for jarvis-proto
on:
pull_request:
branches:
- master
paths:
- docker/**
pull_request:
branches:
- master
paths:
- docker/**
permissions:
contents: 'read'
id-token: 'write'
contents: read
id-token: write
jobs:
build:
name: Build and publish Test image
env:
GCR_URL: gcr.io
GCP_PROJECT_ID: jarvis-dev-268314
SSH_KEY: ${{ secrets.SSH_KEY }}
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- id: get_version
run: |
version=`cat ./docker/ForJarvisProtoLocal.Dockerfile | sed -nr 's/.*version="(.+)"/\1/p'`
echo "version=$version" >> $GITHUB_OUTPUT
- name: setup buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Setup GCP Auth
id: auth
uses: google-github-actions/auth@v2
with:
workload_identity_provider: 'projects/699926043561/locations/global/workloadIdentityPools/github-dev/providers/github-dev-provider'
service_account: 'terraform-provider-indykite@jarvis-dev-268314.iam.gserviceaccount.com'
- name: login to container registry
run: |
gcloud auth configure-docker -q
- name: Build, Tag and Publish docker image
run: |
cd docker
docker buildx build --push --squash --build-arg SSH_PRIVATE_KEY="${SSH_KEY}" --tag ${GCR_URL}/${GCP_PROJECT_ID}/test/terraform-tests-for-local-jarvis:latest --tag ${GCR_URL}/${GCP_PROJECT_ID}/test/terraform-tests-for-local-jarvis:${{ steps.get_version.outputs.version }} --platform linux/amd64,linux/arm64 -f ForJarvisProtoLocal.Dockerfile .
build:
name: Build and publish Test image
env:
GCR_URL: gcr.io
GCP_PROJECT_ID: jarvis-dev-268314
SSH_KEY: ${{ secrets.SSH_KEY }}
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- id: get_version
run: |
version=`cat ./docker/ForJarvisProtoLocal.Dockerfile | sed -nr 's/.*version="(.+)"/\1/p'`
echo "version=$version" >> $GITHUB_OUTPUT
- name: setup buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Setup GCP Auth
id: auth
uses: google-github-actions/auth@v2
with:
workload_identity_provider: projects/699926043561/locations/global/workloadIdentityPools/github-dev/providers/github-dev-provider
service_account: terraform-provider-indykite@jarvis-dev-268314.iam.gserviceaccount.com
- name: login to container registry
run: |
gcloud auth configure-docker -q
- name: Build, Tag and Publish docker image
run: |
cd docker
docker buildx build --push --squash --build-arg SSH_PRIVATE_KEY="${SSH_KEY}" --tag ${GCR_URL}/${GCP_PROJECT_ID}/test/terraform-tests-for-local-jarvis:latest --tag ${GCR_URL}/${GCP_PROJECT_ID}/test/terraform-tests-for-local-jarvis:${{ steps.get_version.outputs.version }} --platform linux/amd64,linux/arm64 -f ForJarvisProtoLocal.Dockerfile .
48 changes: 24 additions & 24 deletions .github/workflows/go-integration.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
---
name: Integration Tests
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- master
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- master
workflow_dispatch:
concurrency:
group: integration-${{ github.ref }}
cancel-in-progress: true
group: integration-${{ github.ref }}
cancel-in-progress: true

jobs:
test-integration:
name: Integration Tests
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
env:
INDYKITE_APPLICATION_CREDENTIALS: ${{ secrets.SERVICE_ACCOUNT_CREDENTIALS }}
CUSTOMER_ID: ${{secrets.CUSTOMER_ID}}
steps:
- name: Check out code
uses: actions/checkout@v4
test-integration:
name: Integration Tests
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
env:
INDYKITE_APPLICATION_CREDENTIALS: ${{ secrets.SERVICE_ACCOUNT_CREDENTIALS }}
CUSTOMER_ID: ${{secrets.CUSTOMER_ID}}
steps:
- name: Check out code
uses: actions/checkout@v4

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

- name: Terraform Init and Apply
run: |
make build_test_local_plugin integration
- name: Terraform Init and Apply
run: |
make build_test_local_plugin integration
19 changes: 15 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ linters:
- gosec
- gosmopolitan
- grouper
- inamedparam
- intrange
- lll
- loggercheck
- makezero
Expand All @@ -55,8 +57,10 @@ linters:
- nolintlint
- nonamedreturns
- nosprintfhostport
- perfsprint
- prealloc
- predeclared
# - protogetter # TODO enable
- reassign
- revive
- tagalign
Expand Down Expand Up @@ -88,7 +92,7 @@ linters-settings:
checks: [all]

govet:
check-shadowing: true
shadow: true
enable-all: true

gocritic:
Expand All @@ -100,12 +104,14 @@ linters-settings:
- opinionated
disabled-checks:
- whyNoLint # Is checked by nolintlint with excluding lll much easier
- deferInLoop # Checked by revive already
- dupBranchBody # Checked by revive already

goheader:
values:
regexp:
# As long we decide which format of YEAR in copyright we want, add this hack
our_year: 202[2-3] # Just change to 202[2-3] or other when changed
our_year: 202[2-4] # Just change to 202[2-3] or other when changed
template: |-
Copyright (c) {{OUR_YEAR}} IndyKite
Expand All @@ -121,6 +127,9 @@ linters-settings:
See the License for the specific language governing permissions and
limitations under the License.
ginkgolinter:
forbid-focus-container: true

nakedret:
max-func-lines: 8 # Counting also declaration, not just body

Expand Down Expand Up @@ -198,7 +207,10 @@ linters-settings:
# - name: unchecked-type-assertion # Probably not in TF providers
- name: unconditional-recursion
- name: unexported-naming
- name: unhandled-error
- name: unhandled-error # It is OK not to check errors from some specific cases
arguments:
- (?i)fmt\.(F|S)?Print(ln|f)?
- (bytes\.Buffer|strings\.Builder)\.Write(Byte|String|Rune)?
- name: unnecessary-stmt
- name: unused-receiver
- name: use-any
Expand All @@ -207,7 +219,6 @@ linters-settings:

usestdlibvars:
default-rpc-path: true
os-dev-null: true
sql-isolation-level: true

issues:
Expand Down
11 changes: 6 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ repos:
hooks:
- id: yamlfmt

- repo: https://github.com/jumanjihouse/pre-commit-hooks.git
rev: 3.0.0 # Do not update from 2.1.6 to 3.0.0 unless macOS comes with Ruby 2.7
hooks:
- id: markdownlint
exclude: ^CHANGELOG.md|docs/.*\.md$ # Exclude auto generated
# We don't fix it now anyway, just ignore check for now
# - repo: https://github.com/jumanjihouse/pre-commit-hooks.git
# rev: 2.1.6 # Do not update from 2.1.6 to 3.0.0 unless macOS comes with Ruby 2.7
# hooks:
# - id: markdownlint
# exclude: ^CHANGELOG.md|docs/.*\.md$ # Exclude auto generated

- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.16.0
Expand Down
2 changes: 0 additions & 2 deletions docs/resources/token_introspect.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
resource "indykite_application_agent_credential" "with-public" {
app_agent_id = data.indykite_application_agent.opa.id
display_name = "Key with custom private-public key pair"
expire_time = "2040-12-31T12:34:56-01:00"
public_key_jwk = <<-EOT
app_agent_id = data.indykite_application_agent.opa.id
display_name = "Key with custom private-public key pair"
expire_time = "2040-12-31T12:34:56-01:00"
public_key_jwk = <<-EOT
{
"kty": "EC",
"use": "sig",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/hashicorp/go-cty v1.4.1-0.20200723130312-85980079f637
github.com/hashicorp/terraform-plugin-go v0.23.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
github.com/indykite/indykite-sdk-go v0.29.1
github.com/indykite/indykite-sdk-go v0.30.0
github.com/onsi/ginkgo/v2 v2.19.0
github.com/onsi/gomega v1.33.1
github.com/pborman/uuid v1.2.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S
github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc=
github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE=
github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ=
github.com/indykite/indykite-sdk-go v0.29.1 h1:eT1Pudze3wyVsEH6a77s+EKwRzigx04U0r5KoygiEr4=
github.com/indykite/indykite-sdk-go v0.29.1/go.mod h1:ejizEdrYsb8V0MRYZYofPOuD4DFqDyUe93IflC+O3jI=
github.com/indykite/indykite-sdk-go v0.30.0 h1:haOYxhWV4rbhsDp7j5VHbUw0BP6scNUECG4ZQBhwk1Y=
github.com/indykite/indykite-sdk-go v0.30.0/go.mod h1:ejizEdrYsb8V0MRYZYofPOuD4DFqDyUe93IflC+O3jI=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c=
Expand Down
2 changes: 1 addition & 1 deletion indykite/indykite_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type terraformGomockTestReporter struct {

type GomockTestCleanuper interface {
gomock.TestHelper
Cleanup(func())
Cleanup(fn func())
}

func TestIndykite(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions indykite/test/matchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package test

import (
"errors"
"fmt"

"github.com/onsi/gomega/format"
Expand Down Expand Up @@ -49,7 +50,7 @@ func (m *matcherWrapper) Matches(x any) bool {
}

func (m *matcherWrapper) String() string {
return fmt.Sprintf("Wrapped Gomega fail message: %s", m.matcher.FailureMessage(m.actual))
return "Wrapped Gomega fail message: %s" + m.matcher.FailureMessage(m.actual)
}

// EqualProto uses proto.Equal to compare actual with expected. Equal is strict about
Expand All @@ -74,7 +75,7 @@ func (matcher *equalProtoMatcher) GomegaString() string {
func (matcher *equalProtoMatcher) Match(actual any) (bool, error) {
if actual == nil && matcher.Expected == nil {
//nolint:lll
return false, fmt.Errorf("refusing to compare <nil> to <nil>.\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized")
return false, errors.New("refusing to compare <nil> to <nil>.\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized")
}
var err error
if a, ok := actual.(*anypb.Any); ok {
Expand Down
2 changes: 1 addition & 1 deletion tests/provider/provider.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
indykite = {
source = "indykite/indykite"
source = "indykite/indykite"
version = ">=0.0.1" # Keep hardcoded version >=0.0.1 as provider is build locally with this version
}
}
Expand Down
Loading

0 comments on commit eb985f0

Please sign in to comment.