Skip to content

Commit

Permalink
fix: align structure with scaffolding framework (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
1riatsila1 authored Nov 1, 2024
1 parent 4319012 commit 4523097
Show file tree
Hide file tree
Showing 68 changed files with 80 additions and 135 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/lint-test-code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ jobs:
run: just setup-dev

- name: Run Code Linting Test
run: just lint >> "$GITHUB_STEP_SUMMARY"
run: just lint

- name: Check package files up to date
run: |
just tidy
git diff --exit-code -- pkg/config-api-client/go.* pkg/config-api-provider/go.*
git diff --exit-code -- go.* pkg/config-api-client/go.*
- name: Run Tests
run: |
Expand All @@ -51,7 +51,7 @@ jobs:
- name: Check Provider docs up to date
run: |
just generate-provider-docs
git diff --exit-code -- pkg/config-api-provider/docs
git diff --exit-code -- docs
- name: Check Provider docs valid
run: just validate-provider-docs
Expand All @@ -60,6 +60,6 @@ jobs:
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./pkg/config-api-client/.coverage,./pkg/config-api-provider/.coverage
files: ./pkg/config-api-client/.coverage,.coverage
flage: client,provider
fail_ci_if_error: true
55 changes: 16 additions & 39 deletions Justfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TMP_DIR := "tmp"
CONFIG_API_CLIENT_DIR := "pkg/config-api-client"
CONFIG_API_PROVIDER_DIR := "pkg/config-api-provider"
CONFIG_API_PROVIDER_DIR := "."
TOOLS_PROVIDER_DIR := "tools"
OPENAPI_SPEC := "pkg/config-api-client/api"
SOURCE_OPEN_API_SPEC_FILE := ".openapi.source.yaml"
Expand All @@ -12,11 +12,11 @@ retrieve-config-api-openapi-spec:
cp {{ TMP_DIR }}/oas/openapi.yaml {{ OPENAPI_SPEC }}/{{ SOURCE_OPEN_API_SPEC_FILE }}
rm -rf {{ TMP_DIR }}

cleanup-old-files:
cleanup-old-client-files:
cd {{ CONFIG_API_CLIENT_DIR }} && cat .openapi-generator/FILES | xargs -n 1 rm -f

generate-config-api-client: retrieve-config-api-openapi-spec
just cleanup-old-files
just cleanup-old-client-files
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \
--input-spec /local/{{ OPENAPI_SPEC }}/{{ SOURCE_OPEN_API_SPEC_FILE }} \
--generator-name go \
Expand Down Expand Up @@ -45,56 +45,41 @@ fmt-client:
tidy-client:
cd {{ CONFIG_API_CLIENT_DIR }} && go mod tidy

lint-client:
#!/usr/bin/env bash
cd pkg/config-api-client

if [ -n "$(gofmt -d .)" ]; then
echo "Error: (gofmt) formatting required" >&2
exit 1
fi

if [ -n "$(golines . --dry-run)" ]; then
echo "Error: (golines) formatting required" >&2
exit 1
fi

golangci-lint run

lint-provider:
lint:
#!/usr/bin/env bash
cd pkg/config-api-provider

if [ -n "$(gofmt -d .)" ]; then
output=$(gofmt -d .)
if [ -n "$output" ]; then
echo "$output"
echo "Error: (gofmt) formatting required" >&2
exit 1
fi

if [ -n "$(golines . --dry-run)" ]; then
output=$(golines . --dry-run)
if [ -n "$output" ]; then
echo "$output"
echo "Error: (golines) formatting required" >&2
exit 1
fi

golangci-lint run

fmt-provider:
gofmt -w {{ CONFIG_API_PROVIDER_DIR }}
golines -w {{ CONFIG_API_PROVIDER_DIR }}
fmt:
gofmt -w .
golines -w .

tidy-provider:
cd {{ CONFIG_API_PROVIDER_DIR }} && go mod tidy
cd {{ CONFIG_API_PROVIDER_DIR }} go mod tidy

test-provider +ARGS='':
cd {{ CONFIG_API_PROVIDER_DIR }} && TF_ACC=1 go test -v ./... -race -covermode=atomic -coverprofile=.coverage {{ ARGS }}

generate-provider-docs:
cd {{ TOOLS_PROVIDER_DIR }} && go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate --provider-dir ../{{ CONFIG_API_PROVIDER_DIR }} -provider-name uxi
cd {{ TOOLS_PROVIDER_DIR }} && go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate --provider-dir ../{{ CONFIG_API_PROVIDER_DIR }} --provider-name uxi
sed -i.backup '/subcategory: ""/d' ./{{ CONFIG_API_PROVIDER_DIR }}/docs/index.md && rm ./{{ CONFIG_API_PROVIDER_DIR }}/docs/index.md.backup

validate-provider-docs:
cd {{ TOOLS_PROVIDER_DIR }} && go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs validate --provider-dir ../{{ CONFIG_API_PROVIDER_DIR }} -provider-name uxi
cd {{ TOOLS_PROVIDER_DIR }} && go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs validate --provider-dir ../{{ CONFIG_API_PROVIDER_DIR }} --provider-name uxi

coverage-provider:
cd {{ CONFIG_API_PROVIDER_DIR }} && go tool cover -html=.coverage -o=.coverage.html
Expand All @@ -110,14 +95,6 @@ coverage:
just coverage-client
just coverage-provider

lint:
just lint-client
just lint-provider

fmt:
just fmt-client
just fmt-provider

tidy:
just tidy-client
just tidy-provider
Expand Down
9 changes: 0 additions & 9 deletions cmd/client_tester/go.mod

This file was deleted.

23 changes: 0 additions & 23 deletions cmd/client_tester/main.go

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions pkg/config-api-provider/go.mod → go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration
module github.com/aruba-uxi/configuration-api-terraform-provider

go 1.21

Expand Down Expand Up @@ -68,4 +68,4 @@ require (
google.golang.org/protobuf v1.34.0 // indirect
)

replace github.com/aruba-uxi/configuration-api-terraform-provider/pkg/config-api-client => ../config-api-client
replace github.com/aruba-uxi/configuration-api-terraform-provider/pkg/config-api-client => ./pkg/config-api-client
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package datasources
import (
"context"

"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider/util"
config_api_client "github.com/aruba-uxi/configuration-api-terraform-provider/pkg/config-api-client"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider/util"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package datasources
import (
"context"

"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider/util"
config_api_client "github.com/aruba-uxi/configuration-api-terraform-provider/pkg/config-api-client"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider/util"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package datasources
import (
"context"

"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider/util"
config_api_client "github.com/aruba-uxi/configuration-api-terraform-provider/pkg/config-api-client"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider/util"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package datasources
import (
"context"

"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider/util"
config_api_client "github.com/aruba-uxi/configuration-api-terraform-provider/pkg/config-api-client"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider/util"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package datasources
import (
"context"

"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider/util"
config_api_client "github.com/aruba-uxi/configuration-api-terraform-provider/pkg/config-api-client"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider/util"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package datasources
import (
"context"

"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider/util"
config_api_client "github.com/aruba-uxi/configuration-api-terraform-provider/pkg/config-api-client"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider/util"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package datasources
import (
"context"

"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider/util"
config_api_client "github.com/aruba-uxi/configuration-api-terraform-provider/pkg/config-api-client"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider/util"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"os"

datasources "github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider/data-sources"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider/resources"
"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider/datasources"
"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider/resources"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/provider"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package resources
import (
"context"

"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider/util"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/config-api-client"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider/util"

"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package resources
import (
"context"

"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider/util"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/config-api-client"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider/util"

"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package resources

import (
"context"
"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider/util"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/config-api-client"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider/util"

"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package resources

import (
"context"
"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider/util"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/config-api-client"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider/util"

"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package resources
import (
"context"

"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider/util"
config_api_client "github.com/aruba-uxi/configuration-api-terraform-provider/pkg/config-api-client"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider/util"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package resources

import (
"context"
"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider/util"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/config-api-client"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider/util"

"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package resources
import (
"context"

"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider/util"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/config-api-client"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider/util"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package resources
import (
"context"

"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider/util"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/config-api-client"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider/util"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strconv"
"time"

"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider/config"
"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider/config"
)

func RetryFor429[T any](f func() (T, *http.Response, error)) (T, *http.Response, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/config-api-provider/main.go → main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"flag"
"log"

"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/provider"
"github.com/aruba-uxi/configuration-api-terraform-provider/internal/provider"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"regexp"
"testing"

"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/test/provider"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/test/util"
"github.com/aruba-uxi/configuration-api-terraform-provider/test/provider"
"github.com/aruba-uxi/configuration-api-terraform-provider/test/util"
"github.com/h2non/gock"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"regexp"
"testing"

"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/test/provider"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/test/util"
"github.com/aruba-uxi/configuration-api-terraform-provider/test/provider"
"github.com/aruba-uxi/configuration-api-terraform-provider/test/util"
"github.com/h2non/gock"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"regexp"
"testing"

"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/test/provider"
"github.com/aruba-uxi/configuration-api-terraform-provider/pkg/terraform-provider-configuration/test/util"
"github.com/aruba-uxi/configuration-api-terraform-provider/test/provider"
"github.com/aruba-uxi/configuration-api-terraform-provider/test/util"
"github.com/h2non/gock"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/terraform"
Expand Down
Loading

0 comments on commit 4523097

Please sign in to comment.