diff --git a/.gitattributes b/.gitattributes index 3fcee21f2..50335fced 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,3 @@ *.tm linguist-language=HCL +* text=auto +_*.tf text eol=lf diff --git a/.github/workflows/ci-experimental.yml b/.github/workflows/ci-experimental.yml index bc3d084c0..abc3e67b8 100644 --- a/.github/workflows/ci-experimental.yml +++ b/.github/workflows/ci-experimental.yml @@ -41,7 +41,7 @@ jobs: run: make build - name: make generate - run: make generate + run: make generate && git diff - name: make test run: make test diff --git a/.github/workflows/ci.yml b/.github/workflows/ci-sync-deployment.yml similarity index 67% rename from .github/workflows/ci.yml rename to .github/workflows/ci-sync-deployment.yml index b558007b4..cc0036f8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci-sync-deployment.yml @@ -8,43 +8,28 @@ on: branches: - main - v0.4.x - pull_request: + - v0.6.x + - v0.9.x jobs: - checks: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - uses: actions/setup-go@v4 - with: - go-version: '1.21' - - - name: build Terramate - run: make build - - - name: checking go mod tidyness - run: ./bin/terramate run --tags golang --changed -- make mod/check - - - name: linting code - run: ./bin/terramate run --tags golang --changed -- make lint - - - name: checking license on source code - run: ./bin/terramate run --tags golang --changed -- make license/check - build_test: name: Build and Test - runs-on: ${{ matrix.os }} + runs-on: ${{ matrix.os.value }} + permissions: - id-token: write # This is required for requesting the JWT - contents: read # This is required for actions/checkout + id-token: write + contents: read + pull-requests: write + checks: read strategy: + fail-fast: false matrix: - os: ["ubuntu-20.04", "macos-13"] + os: + - name: ubuntu-focal + value: "ubuntu-20.04" + - name: macos-ventura + value: "macos-13" go: ["1.21"] steps: @@ -63,42 +48,58 @@ jobs: tofu_wrapper: false github_token: ${{ secrets.GITHUB_TOKEN }} + - uses: hashicorp/setup-terraform@v3 + with: + terraform_version: "1.7.5" + terraform_wrapper: false + + - name: Install Terramate + uses: terramate-io/terramate-action@i4k-fix-macos + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: build Terramate - run: make build + run: make build && cp -v ./bin/terramate /usr/local/bin/terramate-bin - name: make generate run: make generate - - name: make test - timeout-minutes: 30 - run: ./bin/terramate run --tags golang --changed -- make test - env: - TM_TEST_TERRAFORM_REQUIRED_VERSION: "1.7.5" + ### Check for changed stacks - - name: check cloud info - run: ./bin/terramate run --tags golang --changed -- ./bin/terramate -vv experimental cloud info + - name: List changed stacks + id: list + run: terramate list --tags golang --changed - gh_integration_test: - name: GHA Integration Test + ### Linting - runs-on: "ubuntu-20.04" + - name: linting code + if: steps.list.outputs.stdout + run: make lint - steps: - - uses: actions/checkout@v4 - with: - ref: ${{github.event.pull_request.head.ref}} - repository: ${{github.event.pull_request.head.repo.full_name}} - fetch-depth: 0 + - name: checking go mod tidyness + if: steps.list.outputs.stdout + run: make mod/check - - uses: actions/setup-go@v5 - with: - go-version: '1.21' + - name: checking license on source code + if: steps.list.outputs.stdout + run: make license/check - - name: build Terramate - run: make build + - name: Check Terramate formatting + run: terramate fmt --check - - name: make test/ci - run: ./bin/terramate run --tags golang --changed -- make test/ci + - name: Check Terraform formatting + if: steps.list.outputs.stdout + run: terraform fmt -recursive -check -diff + + ### Run the Terramate tests and create a Cloud deployment + + - name: Run Terraform deployment on changed + if: steps.list.outputs.stdout + timeout-minutes: 30 + run: terramate script run --changed --tags golang --target ${{ matrix.os.name }} --parallel 12 deploy + env: + GITHUB_TOKEN: ${{ github.token }} + TM_TEST_TERRAFORM_REQUIRED_VERSION: "1.7.5" release_dry_run: name: Release Dry Run @@ -158,9 +159,7 @@ jobs: cosign verify-blob --key cosign.pub --signature ${{ env.SIGNATURE_FILE }} ${{ env.CHECKSUM_FILE }} ci: needs: - - checks - build_test - - gh_integration_test runs-on: ubuntu-20.04 steps: - run: echo "All jobs ran successfully" diff --git a/.github/workflows/ci-sync-preview.yml b/.github/workflows/ci-sync-preview.yml new file mode 100644 index 000000000..212c1b21c --- /dev/null +++ b/.github/workflows/ci-sync-preview.yml @@ -0,0 +1,215 @@ +# Copyright 2023 Terramate GmbH +# SPDX-License-Identifier: MPL-2.0 + +name: ci + +on: + pull_request: + +jobs: + build_test: + name: Build and Test + runs-on: ${{ matrix.os.value }} + + permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout + pull-requests: write + checks: read + + strategy: + fail-fast: false + matrix: + os: + - name: ubuntu-focal + value: "ubuntu-20.04" + - name: macos-ventura + value: "macos-13" + go: ["1.21"] + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + + - uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go }} + + - name: check all packages with tests are Terramate Stacks + run: ./hack/check-stacks.sh + + - uses: opentofu/setup-opentofu@v1 + with: + tofu_version: 1.6.2 + tofu_wrapper: false + github_token: ${{ secrets.GITHUB_TOKEN }} + + - uses: hashicorp/setup-terraform@v3 + with: + terraform_version: "1.7.5" + terraform_wrapper: false + + - name: Install Terramate + uses: terramate-io/terramate-action@i4k-fix-macos + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: build Terramate + run: make build && cp -v ./bin/terramate /usr/local/bin/terramate-bin + + - name: make generate + run: make generate + + ### Check for changed stacks + + - name: List changed stacks + id: list + run: terramate list --tags golang --changed + + ### Linting + + - name: linting code + if: steps.list.outputs.stdout + run: make lint + + - name: checking go mod tidyness + if: steps.list.outputs.stdout + run: make mod/check + + - name: checking license on source code + if: steps.list.outputs.stdout + run: make license/check + + - name: Check Terramate formatting + run: terramate fmt --check + + - name: Check Terraform formatting + if: steps.list.outputs.stdout + run: terraform fmt -recursive -check -diff + + ### Run the Terramate tests and create a Cloud Preview + + - name: Temporary PR Preview Link generation + run: echo >preview_url.txt "https://cloud.terramate.io/o/terramate-tests/review-requests" + + - name: Run Terraform preview on changed + if: steps.list.outputs.stdout + timeout-minutes: 30 + run: terramate script run --changed --tags golang --target ${{ matrix.os.name }} --parallel 12 preview + env: + GITHUB_TOKEN: ${{ github.token }} + TM_TEST_TERRAFORM_REQUIRED_VERSION: "1.7.5" + + ### Update Pull Request comment + + - name: Generate Preview Comment + if: steps.list.outputs.stdout + id: comment + run: | + echo >>pr-comment.txt "## Preview of ${{ matrix.os.name }}/go${{matrix.go}} tests in ${{ github.event.pull_request.head.sha }}" + echo >>pr-comment.txt + echo >>pr-comment.txt "[:mag: View Details on Terramate Cloud]($(cat preview_url.txt))" + echo >>pr-comment.txt + echo >>pr-comment.txt "### " + echo >>pr-comment.txt + echo >>pr-comment.txt '```bash' + echo >>pr-comment.txt "${{ steps.list.outputs.stdout }}" + echo >>pr-comment.txt '```' + cat pr-comment.txt >>$GITHUB_STEP_SUMMARY + + - name: Inform about no Changed Stacks + if: success() && !steps.list.outputs.stdout + run: | + echo >>pr-comment.txt "## Preview of ${{ matrix.os.name }}/go${{matrix.go}} tests in ${{ github.event.pull_request.head.sha }}" + echo >>pr-comment.txt + echo >>pr-comment.txt "### Changed Stacks" + echo >>pr-comment.txt + echo >>pr-comment.txt 'No changed stacks, no detailed preview will be generated.' + cat pr-comment.txt >>$GITHUB_STEP_SUMMARY + + - name: Inform about failure + if: failure() + run: | + echo >>pr-comment.txt "## Preview of ${{ matrix.os.name }}/go${{matrix.go}} tests in ${{ github.event.pull_request.head.sha }}" + echo >>pr-comment.txt + echo >>pr-comment.txt "[:mag: View Details on Terramate Cloud]($(cat preview_url.txt))" + echo >>pr-comment.txt + echo >>pr-comment.txt "### Changed Stacks" + echo >>pr-comment.txt + echo >>pr-comment.txt '```bash' + echo >>pr-comment.txt "${{ steps.list.outputs.stdout }}" + echo >>pr-comment.txt '```' + echo >>pr-comment.txt ":boom: Generating preview failed. [Please see details on Terramate Cloud]($(cat preview_url.txt))" + cat pr-comment.txt >>$GITHUB_STEP_SUMMARY + + - name: Publish Plans for Changed Stacks + uses: marocchino/sticky-pull-request-comment@v2 + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + header: preview-${{ matrix.os.name }}-go-${{matrix.go}} + path: pr-comment.txt + + release_dry_run: + name: Release Dry Run + + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version: '1.21' + + - name: install cosign + run: go install github.com/sigstore/cosign/v2/cmd/cosign@v2.2.4 + - name: install goreleaser + run: | + curl -sL https://github.com/goreleaser/goreleaser-pro/releases/download/v1.14.0-pro/goreleaser-pro_Linux_x86_64.tar.gz -o /tmp/goreleaser.tar.gz + cd /tmp && tar -xzf goreleaser.tar.gz && chmod +x goreleaser + sudo mv /tmp/goreleaser /usr/local/bin/ + + - name: Create cosign.pub file + run: echo "${{ secrets.COSIGN_PUBLIC_KEY }}" > cosign.pub + + - name: release dry run + run: make release/dry-run + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GORELEASER_KEY: ${{ secrets.GORELEASER_API_KEY }} + FURY_TOKEN: ${{ secrets.FURY_TOKEN}} + COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD}} + COSIGN_PRIVATE_KEY: ${{secrets.COSIGN_PRIVATE_KEY }} + + - name: Locate checksum file + id: find_checksum + run: | + if [ -z "$(ls dist/*checksums.txt)" ]; then + echo "Error: Checksum file not found." + exit 1 + fi + echo "CHECKSUM_FILE=$(ls dist/*checksums.txt)" >> $GITHUB_ENV + + - name: Locate signature file + id: find_signature + run: | + if [ -z "$(ls dist/*checksum*.txt.sig)" ]; then + echo "Error: Signature file not found." + exit 1 + fi + echo "SIGNATURE_FILE=$(ls dist/*checksum*.txt.sig)" >> $GITHUB_ENV + + - name: Verify checksums with cosign + run: | + cosign verify-blob --key cosign.pub --signature ${{ env.SIGNATURE_FILE }} ${{ env.CHECKSUM_FILE }} + ci: + needs: + - build_test + runs-on: ubuntu-20.04 + steps: + - run: echo "All jobs ran successfully" diff --git a/.gitignore b/.gitignore index 9ee7410de..fc2604bad 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ coverage.txt cpu.prof mem.prof *.test +*.tfplan *.plan # Go Workspaces artifacts diff --git a/_test_mock.tf b/_test_mock.tf new file mode 100644 index 000000000..0b5673fc9 --- /dev/null +++ b/_test_mock.tf @@ -0,0 +1,14 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "terramate" { + content = <<-EOT +package terramate // import "github.com/terramate-io/terramate" + +Package terramate provides functions for managing terraform stacks. A stack is a +unit of independent runnable terraform modules. + +func Version() string +EOT + + filename = "${path.module}/mock-terramate.ignore" +} diff --git a/cloud/_test_mock.tf b/cloud/_test_mock.tf new file mode 100644 index 000000000..98db963c5 --- /dev/null +++ b/cloud/_test_mock.tf @@ -0,0 +1,87 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "cloud" { + content = <<-EOT +package cloud // import "github.com/terramate-io/terramate/cloud" + +Package cloud implements a client SDK for communication with the cloud API. + +Package cloud implements the SDK for communicating with the Terramate Cloud. + +const WellKnownCLIPath = "/.well-known/cli.json" ... +const PreviewsPath = "/v1/previews" ... +const BaseURL = "https://" + Host +const DefaultLogBatchSize = 256 +const DefaultLogSyncInterval = 1 * time.Second +const ErrNotFound errors.Kind = "resource not found (HTTP Status 404)" +const ErrUnexpectedResponseBody errors.Kind = "unexpected API response body" +const ErrUnexpectedStatus errors.Kind = "unexpected status code" +const Host = "api.terramate.io" +func Get[T Resource](ctx context.Context, client *Client, u url.URL) (entity T, err error) +func Patch[T Resource](ctx context.Context, client *Client, payload interface{}, url url.URL) (entity T, err error) +func Post[T Resource](ctx context.Context, client *Client, payload interface{}, url url.URL) (entity T, err error) +func Put[T Resource](ctx context.Context, client *Client, payload interface{}, url url.URL) (entity T, err error) +func Request[T Resource](ctx context.Context, c *Client, method string, url url.URL, postBody io.Reader) (entity T, err error) +type Author struct{ ... } +type ChangesetDetails struct{ ... } +type Client struct{ ... } +type CommandLog struct{ ... } +type CommandLogs []*CommandLog +type CreatePreviewOpts struct{ ... } +type CreatePreviewPayloadRequest struct{ ... } +type CreatePreviewResponse struct{ ... } +type CreatedPreview struct{ ... } +type Credential interface{ ... } +type DeploymentMetadata struct{ ... } +type DeploymentStackRequest struct{ ... } +type DeploymentStackRequests []DeploymentStackRequest +type DeploymentStackResponse struct{ ... } +type DeploymentStacksPayloadRequest struct{ ... } +type DeploymentStacksResponse []DeploymentStackResponse +type Drift struct{ ... } +type DriftStackPayloadRequest struct{ ... } +type DriftStackPayloadRequests []DriftStackPayloadRequest +type Drifts []Drift +type DriftsStackPayloadResponse struct{ ... } +type EmptyResponse string +type GitMetadata struct{ ... } +type GithubMetadata struct{ ... } +type GitlabMetadata struct{ ... } +type Label struct{ ... } +type LogChannel int + const StdoutLogChannel LogChannel ... +type LogSyncer struct{ ... } + func NewLogSyncer(syncfn Syncer) *LogSyncer + func NewLogSyncerWith(syncfn Syncer, batchSize int, syncInterval time.Duration) *LogSyncer +type MemberOrganization struct{ ... } +type MemberOrganizations []MemberOrganization +type PaginatedResult struct{ ... } +type PreviewStack struct{ ... } +type PreviewStacks []PreviewStack +type Resource interface{ ... } +type ResponsePreviewStack struct{ ... } +type ResponsePreviewStacks []ResponsePreviewStack +type ReviewRequest struct{ ... } +type ReviewRequestResponse struct{ ... } +type ReviewRequestResponsePayload struct{ ... } +type ReviewRequestResponses []ReviewRequestResponse +type Reviewer Author +type Reviewers []Reviewer +type RunContext struct{ ... } +type Stack struct{ ... } +type StackObject struct{ ... } +type StacksResponse struct{ ... } +type StatusFilters struct{ ... } + func NoStatusFilters() StatusFilters +type Syncer func(l CommandLogs) +type UUID string +type UpdateDeploymentStack struct{ ... } +type UpdateDeploymentStacks struct{ ... } +type UpdateStackPreviewOpts struct{ ... } +type UpdateStackPreviewPayloadRequest struct{ ... } +type User struct{ ... } +type WellKnown struct{ ... } +EOT + + filename = "${path.module}/mock-cloud.ignore" +} diff --git a/cloud/deployment/_test_mock.tf b/cloud/deployment/_test_mock.tf new file mode 100644 index 000000000..a96b3a2c6 --- /dev/null +++ b/cloud/deployment/_test_mock.tf @@ -0,0 +1,19 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "deployment" { + content = <<-EOT +package deployment // import "github.com/terramate-io/terramate/cloud/deployment" + +Package deployment provides types and helpers for cloud deployments. + +const ErrInvalidStatus errors.Kind = "invalid deployment status" ... +type FilterStatus Status + const UnhealthyFilter FilterStatus = FilterStatus(^OK) ... + func NewStatusFilter(str string) (FilterStatus, error) +type Status uint8 + const OK Status = 1 << iota ... + func NewStatus(str string) Status +EOT + + filename = "${path.module}/mock-deployment.ignore" +} diff --git a/cloud/deployment/stack.tm.hcl b/cloud/deployment/stack.tm.hcl new file mode 100644 index 000000000..1d2d741fa --- /dev/null +++ b/cloud/deployment/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package deployment // import \"github.com/terramate-io/terramate/cloud/deployment\"" + description = "package deployment // import \"github.com/terramate-io/terramate/cloud/deployment\"\n\nPackage deployment provides types and helpers for cloud deployments.\n\nconst ErrInvalidStatus errors.Kind = \"invalid deployment status\" ...\ntype FilterStatus Status\n const UnhealthyFilter FilterStatus = FilterStatus(^OK) ...\n func NewStatusFilter(str string) (FilterStatus, error)\ntype Status uint8\n const OK Status = 1 << iota ...\n func NewStatus(str string) Status" + tags = ["cloud", "deployment", "golang"] + id = "fcad074d-7f0e-491d-a72a-02939b4bb9be" +} diff --git a/cloud/drift/_test_mock.tf b/cloud/drift/_test_mock.tf new file mode 100644 index 000000000..2edf708bc --- /dev/null +++ b/cloud/drift/_test_mock.tf @@ -0,0 +1,19 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "drift" { + content = <<-EOT +package drift // import "github.com/terramate-io/terramate/cloud/drift" + +Package drift provides types and helpers for cloud drifts. + +const ErrInvalidStatus errors.Kind = "invalid drift status" ... +type FilterStatus Status + const UnhealthyFilter FilterStatus = FilterStatus(^OK) ... + func NewStatusFilter(str string) (FilterStatus, error) +type Status uint8 + const OK Status = 1 << iota ... + func NewStatus(str string) Status +EOT + + filename = "${path.module}/mock-drift.ignore" +} diff --git a/cloud/drift/stack.tm.hcl b/cloud/drift/stack.tm.hcl new file mode 100644 index 000000000..5af1c84a6 --- /dev/null +++ b/cloud/drift/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package drift // import \"github.com/terramate-io/terramate/cloud/drift\"" + description = "package drift // import \"github.com/terramate-io/terramate/cloud/drift\"\n\nPackage drift provides types and helpers for cloud drifts.\n\nconst ErrInvalidStatus errors.Kind = \"invalid drift status\" ...\ntype FilterStatus Status\n const UnhealthyFilter FilterStatus = FilterStatus(^OK) ...\n func NewStatusFilter(str string) (FilterStatus, error)\ntype Status uint8\n const OK Status = 1 << iota ...\n func NewStatus(str string) Status" + tags = ["cloud", "drift", "golang"] + id = "e4f72263-bee0-4dee-82d2-28ad9dd8516f" +} diff --git a/cloud/preview/_test_mock.tf b/cloud/preview/_test_mock.tf new file mode 100644 index 000000000..94c504807 --- /dev/null +++ b/cloud/preview/_test_mock.tf @@ -0,0 +1,18 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "preview" { + content = <<-EOT +package preview // import "github.com/terramate-io/terramate/cloud/preview" + +Package preview contains functionality for the preview feature in Terramate +Cloud. + +const ErrInvalidStackStatus = errors.Kind("invalid stack status") +type Layer string +type StackStatus string + const StackStatusAffected StackStatus = "affected" ... + func DerivePreviewStatus(exitCode int) StackStatus +EOT + + filename = "${path.module}/mock-preview.ignore" +} diff --git a/cloud/preview/stack.tm.hcl b/cloud/preview/stack.tm.hcl new file mode 100644 index 000000000..f43ee8554 --- /dev/null +++ b/cloud/preview/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package preview // import \"github.com/terramate-io/terramate/cloud/preview\"" + description = "package preview // import \"github.com/terramate-io/terramate/cloud/preview\"\n\nPackage preview contains functionality for the preview feature in Terramate\nCloud.\n\nconst ErrInvalidStackStatus = errors.Kind(\"invalid stack status\")\ntype Layer string\ntype StackStatus string\n const StackStatusAffected StackStatus = \"affected\" ...\n func DerivePreviewStatus(exitCode int) StackStatus" + tags = ["cloud", "golang", "preview"] + id = "de7aef4e-bf44-440b-833e-aebc5e8d2606" +} diff --git a/cloud/stack.tm.hcl b/cloud/stack.tm.hcl new file mode 100644 index 000000000..471fc518e --- /dev/null +++ b/cloud/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package cloud // import \"github.com/terramate-io/terramate/cloud\"" + description = "package cloud // import \"github.com/terramate-io/terramate/cloud\"\n\nPackage cloud implements a client SDK for communication with the cloud API.\n\nPackage cloud implements the SDK for communicating with the Terramate Cloud.\n\nconst WellKnownCLIPath = \"/.well-known/cli.json\" ...\nconst PreviewsPath = \"/v1/previews\" ...\nconst BaseURL = \"https://\" + Host\nconst DefaultLogBatchSize = 256\nconst DefaultLogSyncInterval = 1 * time.Second\nconst ErrNotFound errors.Kind = \"resource not found (HTTP Status 404)\"\nconst ErrUnexpectedResponseBody errors.Kind = \"unexpected API response body\"\nconst ErrUnexpectedStatus errors.Kind = \"unexpected status code\"\nconst Host = \"api.terramate.io\"\nfunc Get[T Resource](ctx context.Context, client *Client, u url.URL) (entity T, err error)\nfunc Patch[T Resource](ctx context.Context, client *Client, payload interface{}, url url.URL) (entity T, err error)\nfunc Post[T Resource](ctx context.Context, client *Client, payload interface{}, url url.URL) (entity T, err error)\nfunc Put[T Resource](ctx context.Context, client *Client, payload interface{}, url url.URL) (entity T, err error)\nfunc Request[T Resource](ctx context.Context, c *Client, method string, url url.URL, postBody io.Reader) (entity T, err error)\ntype Author struct{ ... }\ntype ChangesetDetails struct{ ... }\ntype Client struct{ ... }\ntype CommandLog struct{ ... }\ntype CommandLogs []*CommandLog\ntype CreatePreviewOpts struct{ ... }\ntype CreatePreviewPayloadRequest struct{ ... }\ntype CreatePreviewResponse struct{ ... }\ntype CreatedPreview struct{ ... }\ntype Credential interface{ ... }\ntype DeploymentMetadata struct{ ... }\ntype DeploymentStackRequest struct{ ... }\ntype DeploymentStackRequests []DeploymentStackRequest\ntype DeploymentStackResponse struct{ ... }\ntype DeploymentStacksPayloadRequest struct{ ... }\ntype DeploymentStacksResponse []DeploymentStackResponse\ntype Drift struct{ ... }\ntype DriftStackPayloadRequest struct{ ... }\ntype DriftStackPayloadRequests []DriftStackPayloadRequest\ntype Drifts []Drift\ntype DriftsStackPayloadResponse struct{ ... }\ntype EmptyResponse string\ntype GitMetadata struct{ ... }\ntype GithubMetadata struct{ ... }\ntype GitlabMetadata struct{ ... }\ntype Label struct{ ... }\ntype LogChannel int\n const StdoutLogChannel LogChannel ...\ntype LogSyncer struct{ ... }\n func NewLogSyncer(syncfn Syncer) *LogSyncer\n func NewLogSyncerWith(syncfn Syncer, batchSize int, syncInterval time.Duration) *LogSyncer\ntype MemberOrganization struct{ ... }\ntype MemberOrganizations []MemberOrganization\ntype PaginatedResult struct{ ... }\ntype PreviewStack struct{ ... }\ntype PreviewStacks []PreviewStack\ntype Resource interface{ ... }\ntype ResponsePreviewStack struct{ ... }\ntype ResponsePreviewStacks []ResponsePreviewStack\ntype ReviewRequest struct{ ... }\ntype ReviewRequestResponse struct{ ... }\ntype ReviewRequestResponsePayload struct{ ... }\ntype ReviewRequestResponses []ReviewRequestResponse\ntype Reviewer Author\ntype Reviewers []Reviewer\ntype RunContext struct{ ... }\ntype Stack struct{ ... }\ntype StackObject struct{ ... }\ntype StacksResponse struct{ ... }\ntype StatusFilters struct{ ... }\n func NoStatusFilters() StatusFilters\ntype Syncer func(l CommandLogs)\ntype UUID string\ntype UpdateDeploymentStack struct{ ... }\ntype UpdateDeploymentStacks struct{ ... }\ntype UpdateStackPreviewOpts struct{ ... }\ntype UpdateStackPreviewPayloadRequest struct{ ... }\ntype User struct{ ... }\ntype WellKnown struct{ ... }" + tags = ["cloud", "golang"] + id = "aac72144-ecbc-4a30-92ac-8e2b9113c740" +} diff --git a/cloud/stack/_test_mock.tf b/cloud/stack/_test_mock.tf new file mode 100644 index 000000000..930047d5a --- /dev/null +++ b/cloud/stack/_test_mock.tf @@ -0,0 +1,20 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "stack" { + content = <<-EOT +package stack // import "github.com/terramate-io/terramate/cloud/stack" + +Package stack provides types and helpers for cloud stacks. + +const ErrInvalidStatus errors.Kind = "invalid stack status" ... +const AnyTarget = "" +type FilterStatus Status + const UnhealthyFilter FilterStatus = FilterStatus(Drifted | Failed) ... + func NewStatusFilter(str string) (FilterStatus, error) +type Status uint8 + const OK Status = 1 << iota ... + func NewStatus(str string) Status +EOT + + filename = "${path.module}/mock-stack.ignore" +} diff --git a/cloud/stack/stack.tm.hcl b/cloud/stack/stack.tm.hcl new file mode 100644 index 000000000..21e739d51 --- /dev/null +++ b/cloud/stack/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package stack // import \"github.com/terramate-io/terramate/cloud/stack\"" + description = "package stack // import \"github.com/terramate-io/terramate/cloud/stack\"\n\nPackage stack provides types and helpers for cloud stacks.\n\nconst ErrInvalidStatus errors.Kind = \"invalid stack status\" ...\nconst AnyTarget = \"\"\ntype FilterStatus Status\n const UnhealthyFilter FilterStatus = FilterStatus(Drifted | Failed) ...\n func NewStatusFilter(str string) (FilterStatus, error)\ntype Status uint8\n const OK Status = 1 << iota ...\n func NewStatus(str string) Status" + tags = ["cloud", "golang", "stack"] + id = "6f8698d5-9e2b-47ea-b795-9a98b868fbe6" +} diff --git a/cloud/testserver/_test_mock.tf b/cloud/testserver/_test_mock.tf new file mode 100644 index 000000000..fb55484d2 --- /dev/null +++ b/cloud/testserver/_test_mock.tf @@ -0,0 +1,46 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "testserver" { + content = <<-EOT +package testserver // import "github.com/terramate-io/terramate/cloud/testserver" + +Package testserver provides fake Terramate Cloud endpoints for testing purposes. + +func DisableEndpoints(paths ...string) map[string]bool +func EnableAllConfig() map[string]bool +func GetCommit(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...) +func GetDeploymentLogs(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...) +func GetDeploymentLogsEvents(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...) +func GetDeployments(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...) +func GetDrift(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...) +func GetDrifts(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...) +func GetMemberships(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...) +func GetPreview(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...) +func GetPullRequest(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...) +func GetStackDrifts(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...) +func GetStacks(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...) +func GetUsers(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...) +func GetWellKnown(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...) +func ListCheckRunsForRef(_ *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...) +func ListPullRequestsWithCommit(_ *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...) +func ListReviews(_ *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...) +func PatchDeployment(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...) +func PatchStackPreviews(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...) +func PostDeployment(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...) +func PostDeploymentLogs(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...) +func PostDrift(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...) +func PostPreviews(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...) +func PostStackPreviewsLogs(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...) +func PullRequestIsMerged(_ *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...) +func PutStack(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...) +func Router(store *cloudstore.Data) *httprouter.Router +func RouterAdd(store *cloudstore.Data, router *httprouter.Router, enabled map[string]bool) +func RouterAddCustoms(router *httprouter.Router, store *cloudstore.Data, custom Custom) +func RouterWith(store *cloudstore.Data, enabled map[string]bool) *httprouter.Router +type Custom struct{ ... } +type Handler func(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...) +type Route struct{ ... } +EOT + + filename = "${path.module}/mock-testserver.ignore" +} diff --git a/cloud/testserver/cloudstore/_test_mock.tf b/cloud/testserver/cloudstore/_test_mock.tf new file mode 100644 index 000000000..3daa89f87 --- /dev/null +++ b/cloud/testserver/cloudstore/_test_mock.tf @@ -0,0 +1,26 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "cloudstore" { + content = <<-EOT +package cloudstore // import "github.com/terramate-io/terramate/cloud/testserver/cloudstore" + +Package cloudstore provides the in-memory store used by the fake Terramate Cloud +server. + +const ErrAlreadyExists errors.Kind = "record already exists" ... +type Data struct{ ... } + func LoadDatastore(fpath string) (*Data, error) +type Deployment struct{ ... } +type DeploymentState struct{ ... } +type Drift struct{ ... } +type Member struct{ ... } +type Org struct{ ... } +type Preview struct{ ... } +type Stack struct{ ... } +type StackPreview struct{ ... } +type StackState struct{ ... } + func NewState() StackState +EOT + + filename = "${path.module}/mock-cloudstore.ignore" +} diff --git a/cloud/testserver/cloudstore/stack.tm.hcl b/cloud/testserver/cloudstore/stack.tm.hcl new file mode 100644 index 000000000..9aefbd9ed --- /dev/null +++ b/cloud/testserver/cloudstore/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package cloudstore // import \"github.com/terramate-io/terramate/cloud/testserver/cloudstore\"" + description = "package cloudstore // import \"github.com/terramate-io/terramate/cloud/testserver/cloudstore\"\n\nPackage cloudstore provides the in-memory store used by the fake Terramate Cloud\nserver.\n\nconst ErrAlreadyExists errors.Kind = \"record already exists\" ...\ntype Data struct{ ... }\n func LoadDatastore(fpath string) (*Data, error)\ntype Deployment struct{ ... }\ntype DeploymentState struct{ ... }\ntype Drift struct{ ... }\ntype Member struct{ ... }\ntype Org struct{ ... }\ntype Preview struct{ ... }\ntype Stack struct{ ... }\ntype StackPreview struct{ ... }\ntype StackState struct{ ... }\n func NewState() StackState" + tags = ["cloud", "cloudstore", "golang", "testserver"] + id = "87319590-2a04-4eea-a900-23edab55f7a9" +} diff --git a/cloud/testserver/cmd/testserver/_test_mock.tf b/cloud/testserver/cmd/testserver/_test_mock.tf new file mode 100644 index 000000000..4d1ab5e1a --- /dev/null +++ b/cloud/testserver/cmd/testserver/_test_mock.tf @@ -0,0 +1,9 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "testserver" { + content = <<-EOT +Package main implements the cloudmock service. +EOT + + filename = "${path.module}/mock-testserver.ignore" +} diff --git a/cloud/testserver/cmd/testserver/stack.tm.hcl b/cloud/testserver/cmd/testserver/stack.tm.hcl new file mode 100644 index 000000000..dd743af09 --- /dev/null +++ b/cloud/testserver/cmd/testserver/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "Package main implements the cloudmock service." + description = "Package main implements the cloudmock service." + tags = ["cloud", "cmd", "golang", "testserver"] + id = "69b6f99c-a383-4b62-abf9-463a4feee711" +} diff --git a/cloud/testserver/stack.tm.hcl b/cloud/testserver/stack.tm.hcl new file mode 100644 index 000000000..5ccc0be96 --- /dev/null +++ b/cloud/testserver/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package testserver // import \"github.com/terramate-io/terramate/cloud/testserver\"" + description = "package testserver // import \"github.com/terramate-io/terramate/cloud/testserver\"\n\nPackage testserver provides fake Terramate Cloud endpoints for testing purposes.\n\nfunc DisableEndpoints(paths ...string) map[string]bool\nfunc EnableAllConfig() map[string]bool\nfunc GetCommit(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...)\nfunc GetDeploymentLogs(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...)\nfunc GetDeploymentLogsEvents(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...)\nfunc GetDeployments(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...)\nfunc GetDrift(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...)\nfunc GetDrifts(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...)\nfunc GetMemberships(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...)\nfunc GetPreview(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...)\nfunc GetPullRequest(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...)\nfunc GetStackDrifts(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...)\nfunc GetStacks(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...)\nfunc GetUsers(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...)\nfunc GetWellKnown(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...)\nfunc ListCheckRunsForRef(_ *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...)\nfunc ListPullRequestsWithCommit(_ *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...)\nfunc ListReviews(_ *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...)\nfunc PatchDeployment(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...)\nfunc PatchStackPreviews(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...)\nfunc PostDeployment(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...)\nfunc PostDeploymentLogs(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...)\nfunc PostDrift(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...)\nfunc PostPreviews(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...)\nfunc PostStackPreviewsLogs(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...)\nfunc PullRequestIsMerged(_ *cloudstore.Data, w http.ResponseWriter, _ *http.Request, ...)\nfunc PutStack(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...)\nfunc Router(store *cloudstore.Data) *httprouter.Router\nfunc RouterAdd(store *cloudstore.Data, router *httprouter.Router, enabled map[string]bool)\nfunc RouterAddCustoms(router *httprouter.Router, store *cloudstore.Data, custom Custom)\nfunc RouterWith(store *cloudstore.Data, enabled map[string]bool) *httprouter.Router\ntype Custom struct{ ... }\ntype Handler func(store *cloudstore.Data, w http.ResponseWriter, r *http.Request, ...)\ntype Route struct{ ... }" + tags = ["cloud", "golang", "testserver"] + id = "83b321e3-01a5-4a7b-a318-aa5b30c7888e" +} diff --git a/cmd/terramate-ls/_test_mock.tf b/cmd/terramate-ls/_test_mock.tf new file mode 100644 index 000000000..fa8d00f46 --- /dev/null +++ b/cmd/terramate-ls/_test_mock.tf @@ -0,0 +1,11 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "terramate-ls" { + content = <<-EOT +Terramate-ls is a language server. For details on how to use it just run: + + terramate-ls --help +EOT + + filename = "${path.module}/mock-terramate-ls.ignore" +} diff --git a/cmd/terramate-ls/stack.tm.hcl b/cmd/terramate-ls/stack.tm.hcl new file mode 100644 index 000000000..8a60132c4 --- /dev/null +++ b/cmd/terramate-ls/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "Terramate-ls is a language server. For details on how to use it just run:" + description = "Terramate-ls is a language server. For details on how to use it just run:\n\n terramate-ls --help" + tags = ["cmd", "golang", "terramate-ls"] + id = "5c7b673d-a46a-4bda-abf7-b56b7c43225d" +} diff --git a/cmd/terramate/_test_mock.tf b/cmd/terramate/_test_mock.tf new file mode 100644 index 000000000..4548fcb29 --- /dev/null +++ b/cmd/terramate/_test_mock.tf @@ -0,0 +1,13 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "terramate" { + content = <<-EOT +Terramate is a tool for managing multiple Terraform stacks. Providing stack +execution orchestration and code generation as a way to share data across +different stacks. For details on how to use it just run: + + terramate --help +EOT + + filename = "${path.module}/mock-terramate.ignore" +} diff --git a/cmd/terramate/cli/_test_mock.tf b/cmd/terramate/cli/_test_mock.tf new file mode 100644 index 000000000..c1d970e74 --- /dev/null +++ b/cmd/terramate/cli/_test_mock.tf @@ -0,0 +1,19 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "cli" { + content = <<-EOT +package cli // import "github.com/terramate-io/terramate/cmd/terramate/cli" + +Package cli provides cli specific functionality. + +const ErrCurrentHeadIsOutOfDate errors.Kind = "current HEAD is out-of-date with the remote base branch" ... +const ErrLoginRequired errors.Kind ... +const ProvisionerTerraform = "terraform" ... +const ErrRunFailed errors.Kind = "execution failed" ... +func Exec(version string, args []string, stdin io.Reader, stdout io.Writer, ...) +type UIMode int + const HumanMode UIMode = iota ... +EOT + + filename = "${path.module}/mock-cli.ignore" +} diff --git a/cmd/terramate/cli/cliconfig/_test_mock.tf b/cmd/terramate/cli/cliconfig/_test_mock.tf new file mode 100644 index 000000000..1249819e1 --- /dev/null +++ b/cmd/terramate/cli/cliconfig/_test_mock.tf @@ -0,0 +1,19 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "cliconfig" { + content = <<-EOT +package cliconfig // import "github.com/terramate-io/terramate/cmd/terramate/cli/cliconfig" + +Package cliconfig implements the parser and load of Terramate CLI Configuration +files (.terramaterc and terramate.rc). + +const ErrInvalidAttributeType errors.Kind = "attribute with invalid type" ... +const DirEnv = "HOME" +const Filename = ".terramaterc" +type Config struct{ ... } + func Load() (cfg Config, err error) + func LoadFrom(fname string) (Config, error) +EOT + + filename = "${path.module}/mock-cliconfig.ignore" +} diff --git a/cmd/terramate/cli/cliconfig/stack.tm.hcl b/cmd/terramate/cli/cliconfig/stack.tm.hcl new file mode 100644 index 000000000..ebcaa66d0 --- /dev/null +++ b/cmd/terramate/cli/cliconfig/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package cliconfig // import \"github.com/terramate-io/terramate/cmd/terramate/cli/cliconfig\"" + description = "package cliconfig // import \"github.com/terramate-io/terramate/cmd/terramate/cli/cliconfig\"\n\nPackage cliconfig implements the parser and load of Terramate CLI Configuration\nfiles (.terramaterc and terramate.rc).\n\nconst ErrInvalidAttributeType errors.Kind = \"attribute with invalid type\" ...\nconst DirEnv = \"HOME\"\nconst Filename = \".terramaterc\"\ntype Config struct{ ... }\n func Load() (cfg Config, err error)\n func LoadFrom(fname string) (Config, error)" + tags = ["cli", "cliconfig", "cmd", "golang", "terramate"] + id = "ffda9adf-be7b-47fd-9558-a311bfb8c44c" +} diff --git a/cmd/terramate/cli/clitest/_test_mock.tf b/cmd/terramate/cli/clitest/_test_mock.tf new file mode 100644 index 000000000..6b6921871 --- /dev/null +++ b/cmd/terramate/cli/clitest/_test_mock.tf @@ -0,0 +1,15 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "clitest" { + content = <<-EOT +package clitest // import "github.com/terramate-io/terramate/cmd/terramate/cli/clitest" + +Package clitest provides constants and errors kind reused by the cli +implementation and the e2e test infrastructure. + +const CloudDisablingMessage = "disabling the cloud features" ... +const ErrCloud errors.Kind = "unprocessable cloud feature" ... +EOT + + filename = "${path.module}/mock-clitest.ignore" +} diff --git a/cmd/terramate/cli/clitest/stack.tm.hcl b/cmd/terramate/cli/clitest/stack.tm.hcl new file mode 100644 index 000000000..cf9ab2d47 --- /dev/null +++ b/cmd/terramate/cli/clitest/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package clitest // import \"github.com/terramate-io/terramate/cmd/terramate/cli/clitest\"" + description = "package clitest // import \"github.com/terramate-io/terramate/cmd/terramate/cli/clitest\"\n\nPackage clitest provides constants and errors kind reused by the cli\nimplementation and the e2e test infrastructure.\n\nconst CloudDisablingMessage = \"disabling the cloud features\" ...\nconst ErrCloud errors.Kind = \"unprocessable cloud feature\" ..." + tags = ["cli", "clitest", "cmd", "golang", "terramate"] + id = "5b536408-2561-4011-93e9-da47aa9656cf" +} diff --git a/cmd/terramate/cli/cloud.go b/cmd/terramate/cli/cloud.go index 14c06b7a5..45ad4bfac 100644 --- a/cmd/terramate/cli/cloud.go +++ b/cmd/terramate/cli/cloud.go @@ -73,7 +73,7 @@ const ( // newCloudRequiredError creates an error indicating that a cloud login is required to use requested features. func newCloudRequiredError(requestedFeatures []string) *errors.DetailedError { - err := errors.D("This command uses Terramate Cloud features and requires you to be logged in.") + err := errors.D(clitest.CloudLoginRequiredMessage) for _, s := range requestedFeatures { err = err.WithDetailf(verbosity.V1, "%s", s) @@ -195,7 +195,7 @@ func (c *cli) cloudEnabled() bool { } func (c *cli) disableCloudFeatures(err error) { - log.Warn().Err(err).Msg(clitest.CloudDisablingMessage) + printer.Stderr.WarnWithDetails(clitest.CloudDisablingMessage, errors.E(err.Error())) c.cloud.disabled = true } diff --git a/cmd/terramate/cli/github/_test_mock.tf b/cmd/terramate/cli/github/_test_mock.tf new file mode 100644 index 000000000..6eae02511 --- /dev/null +++ b/cmd/terramate/cli/github/_test_mock.tf @@ -0,0 +1,20 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "github" { + content = <<-EOT +package github // import "github.com/terramate-io/terramate/cmd/terramate/cli/github" + +Package github implements a client SDK for the Github API. + +const ErrNotFound errors.Kind = "resource not found (HTTP Status: 404)" ... +const Domain = "github.com" ... +const ErrGithubEventPathEnvNotSet errors.Kind = `environment variable "GITHUB_EVENT_PATH" not set` ... +func GetEventPR() (*github.PullRequest, error) +func OIDCToken(ctx context.Context, cfg OIDCVars) (token string, err error) +type OAuthDeviceFlowContext struct{ ... } + func OAuthDeviceFlowAuthStart(clientID string) (oauthCtx OAuthDeviceFlowContext, err error) +type OIDCVars struct{ ... } +EOT + + filename = "${path.module}/mock-github.ignore" +} diff --git a/cmd/terramate/cli/github/stack.tm.hcl b/cmd/terramate/cli/github/stack.tm.hcl new file mode 100644 index 000000000..743b1857b --- /dev/null +++ b/cmd/terramate/cli/github/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package github // import \"github.com/terramate-io/terramate/cmd/terramate/cli/github\"" + description = "package github // import \"github.com/terramate-io/terramate/cmd/terramate/cli/github\"\n\nPackage github implements a client SDK for the Github API.\n\nconst ErrNotFound errors.Kind = \"resource not found (HTTP Status: 404)\" ...\nconst Domain = \"github.com\" ...\nconst ErrGithubEventPathEnvNotSet errors.Kind = `environment variable \"GITHUB_EVENT_PATH\" not set` ...\nfunc GetEventPR() (*github.PullRequest, error)\nfunc OIDCToken(ctx context.Context, cfg OIDCVars) (token string, err error)\ntype OAuthDeviceFlowContext struct{ ... }\n func OAuthDeviceFlowAuthStart(clientID string) (oauthCtx OAuthDeviceFlowContext, err error)\ntype OIDCVars struct{ ... }" + tags = ["cli", "cmd", "github", "golang", "terramate"] + id = "5e0c44d6-4b57-4469-acc6-d3a893908e22" +} diff --git a/cmd/terramate/cli/gitlab/_test_mock.tf b/cmd/terramate/cli/gitlab/_test_mock.tf new file mode 100644 index 000000000..7c5fee590 --- /dev/null +++ b/cmd/terramate/cli/gitlab/_test_mock.tf @@ -0,0 +1,17 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "gitlab" { + content = <<-EOT +package gitlab // import "github.com/terramate-io/terramate/cmd/terramate/cli/gitlab" + +Package gitlab provides a SDK and helpers for the gitlab provider. + +const ErrNotFound errors.Kind = "resource not found (HTTP Status: 404)" +type Client struct{ ... } +type MR struct{ ... } +type MRs []MR +type User struct{ ... } +EOT + + filename = "${path.module}/mock-gitlab.ignore" +} diff --git a/cmd/terramate/cli/gitlab/stack.tm.hcl b/cmd/terramate/cli/gitlab/stack.tm.hcl new file mode 100644 index 000000000..1be6fcca0 --- /dev/null +++ b/cmd/terramate/cli/gitlab/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package gitlab // import \"github.com/terramate-io/terramate/cmd/terramate/cli/gitlab\"" + description = "package gitlab // import \"github.com/terramate-io/terramate/cmd/terramate/cli/gitlab\"\n\nPackage gitlab provides a SDK and helpers for the gitlab provider.\n\nconst ErrNotFound errors.Kind = \"resource not found (HTTP Status: 404)\"\ntype Client struct{ ... }\ntype MR struct{ ... }\ntype MRs []MR\ntype User struct{ ... }" + tags = ["cli", "cmd", "gitlab", "golang", "terramate"] + id = "7d36b8af-2c53-4945-93cc-94511e0aefb5" +} diff --git a/cmd/terramate/cli/out/_test_mock.tf b/cmd/terramate/cli/out/_test_mock.tf new file mode 100644 index 000000000..2f4ba27bb --- /dev/null +++ b/cmd/terramate/cli/out/_test_mock.tf @@ -0,0 +1,15 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "out" { + content = <<-EOT +package out // import "github.com/terramate-io/terramate/cmd/terramate/cli/out" + +Package out provides output functionality, including verboseness level and +normal/error messages support. + +type O struct{ ... } + func New(verboseness int, stdout, stderr io.Writer) O +EOT + + filename = "${path.module}/mock-out.ignore" +} diff --git a/cmd/terramate/cli/out/stack.tm.hcl b/cmd/terramate/cli/out/stack.tm.hcl new file mode 100644 index 000000000..70267b927 --- /dev/null +++ b/cmd/terramate/cli/out/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package out // import \"github.com/terramate-io/terramate/cmd/terramate/cli/out\"" + description = "package out // import \"github.com/terramate-io/terramate/cmd/terramate/cli/out\"\n\nPackage out provides output functionality, including verboseness level and\nnormal/error messages support.\n\ntype O struct{ ... }\n func New(verboseness int, stdout, stderr io.Writer) O" + tags = ["cli", "cmd", "golang", "out", "terramate"] + id = "1a00f5ed-e82f-4282-848e-ea9019bdc9e9" +} diff --git a/cmd/terramate/cli/stack.tm.hcl b/cmd/terramate/cli/stack.tm.hcl new file mode 100644 index 000000000..bd77af513 --- /dev/null +++ b/cmd/terramate/cli/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package cli // import \"github.com/terramate-io/terramate/cmd/terramate/cli\"" + description = "package cli // import \"github.com/terramate-io/terramate/cmd/terramate/cli\"\n\nPackage cli provides cli specific functionality.\n\nconst ErrCurrentHeadIsOutOfDate errors.Kind = \"current HEAD is out-of-date with the remote base branch\" ...\nconst ErrLoginRequired errors.Kind ...\nconst ProvisionerTerraform = \"terraform\" ...\nconst ErrRunFailed errors.Kind = \"execution failed\" ...\nfunc Exec(version string, args []string, stdin io.Reader, stdout io.Writer, ...)\ntype UIMode int\n const HumanMode UIMode = iota ..." + tags = ["cli", "cmd", "golang", "terramate"] + id = "695fcfdb-0421-4ea3-b066-3547b1036db0" +} diff --git a/cmd/terramate/stack.tm.hcl b/cmd/terramate/stack.tm.hcl new file mode 100644 index 000000000..0e912eec1 --- /dev/null +++ b/cmd/terramate/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "Terramate is a tool for managing multiple Terraform stacks. Providing stack" + description = "Terramate is a tool for managing multiple Terraform stacks. Providing stack\nexecution orchestration and code generation as a way to share data across\ndifferent stacks. For details on how to use it just run:\n\n terramate --help" + tags = ["cmd", "golang", "terramate"] + id = "19baeccd-97fd-4f79-8e11-755ecb0d865e" +} diff --git a/cmd/tgdeps/_test_mock.tf b/cmd/tgdeps/_test_mock.tf new file mode 100644 index 000000000..b6ac628a2 --- /dev/null +++ b/cmd/tgdeps/_test_mock.tf @@ -0,0 +1,9 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "tgdeps" { + content = <<-EOT +Package main implements tgdeps. +EOT + + filename = "${path.module}/mock-tgdeps.ignore" +} diff --git a/cmd/tgdeps/stack.tm.hcl b/cmd/tgdeps/stack.tm.hcl new file mode 100644 index 000000000..fbdd3950a --- /dev/null +++ b/cmd/tgdeps/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "Package main implements tgdeps." + description = "Package main implements tgdeps." + tags = ["cmd", "golang", "tgdeps"] + id = "15091224-c282-43d9-bbd1-10a90c0957d5" +} diff --git a/config/_test_mock.tf b/config/_test_mock.tf new file mode 100644 index 000000000..30b562be9 --- /dev/null +++ b/config/_test_mock.tf @@ -0,0 +1,50 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "config" { + content = <<-EOT +package config // import "github.com/terramate-io/terramate/config" + +Package config provides high level Terramate configuration facilities. + +const DefaultFilename = "terramate.tm.hcl" ... +const ErrScriptSchema errors.Kind = "script config has an invalid schema" ... +const ErrStackValidation errors.Kind = "validating stack fields" ... +const ErrSchema errors.Kind = "config has an invalid schema" +const MaxScriptDescRunes = 1000 +const MaxScriptNameRunes = 128 +func IsStack(root *Root, dir string) bool +func ReverseStacks(stacks List[*SortableStack]) +func Skip(name string) bool +func ValidateWatchPaths(rootdir string, stackpath string, paths []string) (project.Paths, error) +type Assert struct{ ... } + func EvalAssert(evalctx *eval.Context, cfg hcl.AssertConfig) (Assert, error) +type DirElem interface{ ... } +type Input struct{ ... } + func EvalInput(evalctx *eval.Context, input hcl.Input) (Input, error) +type Inputs []Input +type List[T DirElem] []T + func LoadAllStacks(root *Root, cfg *Tree) (List[*SortableStack], error) + func StacksFromTrees(trees List[*Tree]) (List[*SortableStack], error) +type Output struct{ ... } + func EvalOutput(evalctx *eval.Context, output hcl.Output) (Output, error) +type Outputs []Output +type Root struct{ ... } + func LoadRoot(rootdir string) (*Root, error) + func NewRoot(tree *Tree) *Root + func TryLoadConfig(fromdir string) (tree *Root, configpath string, found bool, err error) +type Script struct{ ... } + func EvalScript(evalctx *eval.Context, script hcl.Script) (Script, error) +type ScriptCmd struct{ ... } +type ScriptCmdOptions struct{ ... } +type ScriptJob struct{ ... } +type SortableStack struct{ ... } +type Stack struct{ ... } + func LoadStack(root *Root, dir project.Path) (*Stack, error) + func NewStackFromHCL(root string, cfg hcl.Config) (*Stack, error) + func TryLoadStack(root *Root, cfgdir project.Path) (stack *Stack, found bool, err error) +type Tree struct{ ... } + func NewTree(cfgdir string) *Tree +EOT + + filename = "${path.module}/mock-config.ignore" +} diff --git a/config/filter/_test_mock.tf b/config/filter/_test_mock.tf new file mode 100644 index 000000000..32a6e515e --- /dev/null +++ b/config/filter/_test_mock.tf @@ -0,0 +1,18 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "filter" { + content = <<-EOT +package filter // import "github.com/terramate-io/terramate/config/filter" + +Package filter provides helpers for filtering objects. + +func MatchTags(filter TagClause, tags []string) bool +func MatchTagsFrom(filters []string, tags []string) (bool, error) +type Operation int + const EQ Operation = iota + 1 ... +type TagClause struct{ ... } + func ParseTagClauses(filters ...string) (TagClause, bool, error) +EOT + + filename = "${path.module}/mock-filter.ignore" +} diff --git a/config/filter/stack.tm.hcl b/config/filter/stack.tm.hcl new file mode 100644 index 000000000..d0373d542 --- /dev/null +++ b/config/filter/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package filter // import \"github.com/terramate-io/terramate/config/filter\"" + description = "package filter // import \"github.com/terramate-io/terramate/config/filter\"\n\nPackage filter provides helpers for filtering objects.\n\nfunc MatchTags(filter TagClause, tags []string) bool\nfunc MatchTagsFrom(filters []string, tags []string) (bool, error)\ntype Operation int\n const EQ Operation = iota + 1 ...\ntype TagClause struct{ ... }\n func ParseTagClauses(filters ...string) (TagClause, bool, error)" + tags = ["config", "filter", "golang"] + id = "a240182f-0b50-4afe-85c7-56e7e288c91c" +} diff --git a/config/stack.tm.hcl b/config/stack.tm.hcl new file mode 100644 index 000000000..b2a0f0037 --- /dev/null +++ b/config/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package config // import \"github.com/terramate-io/terramate/config\"" + description = "package config // import \"github.com/terramate-io/terramate/config\"\n\nPackage config provides high level Terramate configuration facilities.\n\nconst DefaultFilename = \"terramate.tm.hcl\" ...\nconst ErrScriptSchema errors.Kind = \"script config has an invalid schema\" ...\nconst ErrStackValidation errors.Kind = \"validating stack fields\" ...\nconst ErrSchema errors.Kind = \"config has an invalid schema\"\nconst MaxScriptDescRunes = 1000\nconst MaxScriptNameRunes = 128\nfunc IsStack(root *Root, dir string) bool\nfunc ReverseStacks(stacks List[*SortableStack])\nfunc Skip(name string) bool\nfunc ValidateWatchPaths(rootdir string, stackpath string, paths []string) (project.Paths, error)\ntype Assert struct{ ... }\n func EvalAssert(evalctx *eval.Context, cfg hcl.AssertConfig) (Assert, error)\ntype DirElem interface{ ... }\ntype Input struct{ ... }\n func EvalInput(evalctx *eval.Context, input hcl.Input) (Input, error)\ntype Inputs []Input\ntype List[T DirElem] []T\n func LoadAllStacks(root *Root, cfg *Tree) (List[*SortableStack], error)\n func StacksFromTrees(trees List[*Tree]) (List[*SortableStack], error)\ntype Output struct{ ... }\n func EvalOutput(evalctx *eval.Context, output hcl.Output) (Output, error)\ntype Outputs []Output\ntype Root struct{ ... }\n func LoadRoot(rootdir string) (*Root, error)\n func NewRoot(tree *Tree) *Root\n func TryLoadConfig(fromdir string) (tree *Root, configpath string, found bool, err error)\ntype Script struct{ ... }\n func EvalScript(evalctx *eval.Context, script hcl.Script) (Script, error)\ntype ScriptCmd struct{ ... }\ntype ScriptCmdOptions struct{ ... }\ntype ScriptJob struct{ ... }\ntype SortableStack struct{ ... }\ntype Stack struct{ ... }\n func LoadStack(root *Root, dir project.Path) (*Stack, error)\n func NewStackFromHCL(root string, cfg hcl.Config) (*Stack, error)\n func TryLoadStack(root *Root, cfgdir project.Path) (stack *Stack, found bool, err error)\ntype Tree struct{ ... }\n func NewTree(cfgdir string) *Tree" + tags = ["config", "golang"] + id = "f5720006-f59e-44db-b248-6618e9f27bbc" +} diff --git a/config/tag/_test_mock.tf b/config/tag/_test_mock.tf new file mode 100644 index 000000000..eba44081b --- /dev/null +++ b/config/tag/_test_mock.tf @@ -0,0 +1,14 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "tag" { + content = <<-EOT +package tag // import "github.com/terramate-io/terramate/config/tag" + +Package tag provides helpers for dealing with Terramate tags. + +const ErrInvalidTag errors.Kind = "invalid tag" +func Validate(tag string) error +EOT + + filename = "${path.module}/mock-tag.ignore" +} diff --git a/config/tag/stack.tm.hcl b/config/tag/stack.tm.hcl new file mode 100644 index 000000000..480f8df84 --- /dev/null +++ b/config/tag/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package tag // import \"github.com/terramate-io/terramate/config/tag\"" + description = "package tag // import \"github.com/terramate-io/terramate/config/tag\"\n\nPackage tag provides helpers for dealing with Terramate tags.\n\nconst ErrInvalidTag errors.Kind = \"invalid tag\"\nfunc Validate(tag string) error" + tags = ["config", "golang", "tag"] + id = "45241b3c-29b9-4f8a-92ed-84bd479dfae5" +} diff --git a/e2etests/cloud/_test_mock.tf b/e2etests/cloud/_test_mock.tf new file mode 100644 index 000000000..065091f48 --- /dev/null +++ b/e2etests/cloud/_test_mock.tf @@ -0,0 +1,9 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "cloud" { + content = <<-EOT +cloud +EOT + + filename = "${path.module}/mock-cloud.ignore" +} diff --git a/e2etests/cloud/generate-e2e-testserver.tm b/e2etests/cloud/generate-e2e-testserver.tm index 17c379adc..489e5f8bd 100644 --- a/e2etests/cloud/generate-e2e-testserver.tm +++ b/e2etests/cloud/generate-e2e-testserver.tm @@ -1,9 +1,8 @@ // Copyright 2023 Terramate GmbH // SPDX-License-Identifier: MPL-2.0 -generate_file "/e2etests/cloud/testdata/cloud.data.json" { - context = root - +generate_file "testdata/cloud.data.json" { + inherit = false lets { well_known = { required_version = "> 0.4.3" @@ -58,8 +57,8 @@ generate_file "/e2etests/cloud/testdata/cloud.data.json" { } lets { - github_get_pull_request_response = tm_jsondecode(tm_file("e2etests/cloud/testdata/github/get_pull_request_response.json")) - github_get_commit_response = tm_jsondecode(tm_file("e2etests/cloud/testdata/github/get_commit_response.json")) + github_get_pull_request_response = tm_try(tm_jsondecode(tm_file("testdata/github/get_pull_request_response.json")), null) + github_get_commit_response = tm_try(tm_jsondecode(tm_file("testdata/github/get_commit_response.json")), null) } content = tm_jsonencode({ diff --git a/e2etests/cloud/run_cloud_drift_test.go b/e2etests/cloud/run_cloud_drift_test.go index 3deb40572..152c9e7d7 100644 --- a/e2etests/cloud/run_cloud_drift_test.go +++ b/e2etests/cloud/run_cloud_drift_test.go @@ -672,7 +672,6 @@ func TestCLIRunWithCloudSyncDriftStatus(t *testing.T) { } t.Run(name, func(t *testing.T) { t.Parallel() - cloudData, err := cloudstore.LoadDatastore(testserverJSONFile) assert.NoError(t, err) addr := startFakeTMCServer(t, cloudData) @@ -693,11 +692,10 @@ func TestCLIRunWithCloudSyncDriftStatus(t *testing.T) { s.BuildTree(tc.layout) s.Git().CommitAll("all stacks committed") - env := RemoveEnv(os.Environ(), "CI") + env := RemoveEnv(s.Env, "CI") env = append(env, tc.env...) env = append(env, "TMC_API_URL=http://"+addr) cli := NewCLI(t, filepath.Join(s.RootDir(), filepath.FromSlash(tc.workingDir)), env...) - cli.PrependToPath(filepath.Dir(TerraformTestPath)) s.Git().SetRemoteURL("origin", testRemoteRepoURL) runflags := []string{ "run", diff --git a/e2etests/cloud/run_script_cloud_drift_test.go b/e2etests/cloud/run_script_cloud_drift_test.go index 0a89c7825..84e2724b2 100644 --- a/e2etests/cloud/run_script_cloud_drift_test.go +++ b/e2etests/cloud/run_script_cloud_drift_test.go @@ -558,11 +558,10 @@ func TestScriptRunDriftStatus(t *testing.T) { s.BuildTree(tc.layout) s.Git().CommitAll("all stacks committed") - env := RemoveEnv(os.Environ(), "CI") + env := RemoveEnv(s.Env, "CI") env = append(env, tc.env...) env = append(env, "TMC_API_URL=http://"+addr) cli := NewCLI(t, filepath.Join(s.RootDir(), filepath.FromSlash(tc.workingDir)), env...) - cli.PrependToPath(filepath.Dir(TerraformTestPath)) s.Git().SetRemoteURL("origin", testRemoteRepoURL) runflags := []string{ "script", diff --git a/e2etests/cloud/stack.tm.hcl b/e2etests/cloud/stack.tm.hcl new file mode 100644 index 000000000..02e3e293b --- /dev/null +++ b/e2etests/cloud/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "cloud" + description = "cloud" + tags = ["cloud", "e2etests", "golang"] + id = "88f4382b-a453-4228-bf80-788306af8c47" +} diff --git a/e2etests/cmd/helper/_test_mock.tf b/e2etests/cmd/helper/_test_mock.tf new file mode 100644 index 000000000..150425a06 --- /dev/null +++ b/e2etests/cmd/helper/_test_mock.tf @@ -0,0 +1,11 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "helper" { + content = <<-EOT +helper is a utility command that implements behaviors that are useful when +testing terramate run features in a way that reduces dependencies on the +environment to run the tests. +EOT + + filename = "${path.module}/mock-helper.ignore" +} diff --git a/e2etests/cmd/helper/stack.tm.hcl b/e2etests/cmd/helper/stack.tm.hcl new file mode 100644 index 000000000..a8bb82cd2 --- /dev/null +++ b/e2etests/cmd/helper/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "helper is a utility command that implements behaviors that are useful when" + description = "helper is a utility command that implements behaviors that are useful when\ntesting terramate run features in a way that reduces dependencies on the\nenvironment to run the tests." + tags = ["cmd", "e2etests", "golang", "helper"] + id = "b2c8a842-b230-4afd-9d99-47b72d423d54" +} diff --git a/e2etests/core/_test_mock.tf b/e2etests/core/_test_mock.tf new file mode 100644 index 000000000..bf9fcf4a5 --- /dev/null +++ b/e2etests/core/_test_mock.tf @@ -0,0 +1,9 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "core" { + content = <<-EOT +core +EOT + + filename = "${path.module}/mock-core.ignore" +} diff --git a/e2etests/core/run_test.go b/e2etests/core/run_test.go index b8fdfca9c..92022d76f 100644 --- a/e2etests/core/run_test.go +++ b/e2etests/core/run_test.go @@ -3229,8 +3229,6 @@ func TestRunWitCustomizedEnv(t *testing.T) { } wantenv := append(hostenv, - "ACTIONS_ID_TOKEN_REQUEST_URL=", - "ACTIONS_ID_TOKEN_REQUEST_TOKEN=", "CHECKPOINT_DISABLE=1", // e2e tests have telemetry disabled fmt.Sprintf("FROM_META=%s", stackName), fmt.Sprintf("FROM_GLOBAL=%s", stackGlobal), diff --git a/e2etests/core/stack.tm.hcl b/e2etests/core/stack.tm.hcl new file mode 100644 index 000000000..9c7dd93b8 --- /dev/null +++ b/e2etests/core/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "core" + description = "core" + tags = ["core", "e2etests", "golang"] + id = "b36bb769-6f65-467a-9195-f043cd495e16" +} diff --git a/e2etests/internal/runner/_test_mock.tf b/e2etests/internal/runner/_test_mock.tf new file mode 100644 index 000000000..f3b80a6b4 --- /dev/null +++ b/e2etests/internal/runner/_test_mock.tf @@ -0,0 +1,32 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "runner" { + content = <<-EOT +package runner // import "github.com/terramate-io/terramate/e2etests/internal/runner" + +Package runner provides helpers for compiling and running the Terramate binary +with the intent of doing e2e tests. Additionally, it also provides functions for +building and installing dependency binaries. + +var HelperPath string +var HelperPathAsHCL string +var TerraformTestPath string +var TerraformVersion string +func AssertRun(t *testing.T, got RunResult) +func AssertRunResult(t *testing.T, got RunResult, want RunExpected) +func BuildTerramate(projectRoot, binDir string) (string, error) +func BuildTestHelper(projectRoot, binDir string) (string, error) +func InstallTerraform(preferredVersion string) (string, string, func(), error) +func RemoveEnv(environ []string, names ...string) []string +func Setup(projectRoot string) (err error) +func Teardown() +type CLI struct{ ... } + func NewCLI(t *testing.T, chdir string, env ...string) CLI + func NewInteropCLI(t *testing.T, chdir string, env ...string) CLI +type Cmd struct{ ... } +type RunExpected struct{ ... } +type RunResult struct{ ... } +EOT + + filename = "${path.module}/mock-runner.ignore" +} diff --git a/e2etests/internal/runner/runner.go b/e2etests/internal/runner/runner.go index 5323d874a..e9e57df08 100644 --- a/e2etests/internal/runner/runner.go +++ b/e2etests/internal/runner/runner.go @@ -10,6 +10,7 @@ import ( "os/exec" "path/filepath" "regexp" + "slices" "strings" "sync" "testing" @@ -83,14 +84,24 @@ func NewCLI(t *testing.T, chdir string, env ...string) CLI { // by default, it's assumed human mode env = RemoveEnv(os.Environ(), "CI", "GITHUB_ACTIONS", "GITHUB_TOKEN") } + // environments below are never used in automation. + env = RemoveEnv(env, "TMC_API_HOST", "TMC_API_IDP_KEY") + // this needs to be deleted from environment otherwise CLI GHA tests will try to issue JWT tokens. + env = RemoveEnv(env, "ACTIONS_ID_TOKEN_REQUEST_URL", "ACTIONS_ID_TOKEN_REQUEST_TOKEN") + // this must be always disabled otherwise we contaminate the telemetry endpoint. env = append(env, "CHECKPOINT_DISABLE=1") + // sanity check for cases where user has this configured in their environment. + if index := slices.Index(env, "TMC_API_URL"); index >= 0 { + apiURL := env[index] + if !strings.HasPrefix(apiURL, "http://") { + panic("tests are picking up the wrong API URL") + } + } // custom cliconfig file tm.userDir = test.TempDir(t) cliConfigPath := test.WriteFile(t, tm.userDir, "terramate.rc", fmt.Sprintf(testCliConfigFormat, strings.Replace(tm.userDir, "\\", "\\\\", -1))) env = append(env, "TM_CLI_CONFIG_FILE="+cliConfigPath, - "ACTIONS_ID_TOKEN_REQUEST_URL=", - "ACTIONS_ID_TOKEN_REQUEST_TOKEN=", ) tm.environ = env return tm diff --git a/e2etests/internal/runner/stack.tm.hcl b/e2etests/internal/runner/stack.tm.hcl new file mode 100644 index 000000000..347022db8 --- /dev/null +++ b/e2etests/internal/runner/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package runner // import \"github.com/terramate-io/terramate/e2etests/internal/runner\"" + description = "package runner // import \"github.com/terramate-io/terramate/e2etests/internal/runner\"\n\nPackage runner provides helpers for compiling and running the Terramate binary\nwith the intent of doing e2e tests. Additionally, it also provides functions for\nbuilding and installing dependency binaries.\n\nvar HelperPath string\nvar HelperPathAsHCL string\nvar TerraformTestPath string\nvar TerraformVersion string\nfunc AssertRun(t *testing.T, got RunResult)\nfunc AssertRunResult(t *testing.T, got RunResult, want RunExpected)\nfunc BuildTerramate(projectRoot, binDir string) (string, error)\nfunc BuildTestHelper(projectRoot, binDir string) (string, error)\nfunc InstallTerraform(preferredVersion string) (string, string, func(), error)\nfunc RemoveEnv(environ []string, names ...string) []string\nfunc Setup(projectRoot string) (err error)\nfunc Teardown()\ntype CLI struct{ ... }\n func NewCLI(t *testing.T, chdir string, env ...string) CLI\n func NewInteropCLI(t *testing.T, chdir string, env ...string) CLI\ntype Cmd struct{ ... }\ntype RunExpected struct{ ... }\ntype RunResult struct{ ... }" + tags = ["e2etests", "golang", "internal", "runner"] + id = "6d40054a-a8cf-440c-a22b-5f186fd90af2" +} diff --git a/errors/_test_mock.tf b/errors/_test_mock.tf new file mode 100644 index 000000000..5e10f0d60 --- /dev/null +++ b/errors/_test_mock.tf @@ -0,0 +1,29 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "errors" { + content = <<-EOT +package errors // import "github.com/terramate-io/terramate/errors" + +Package errors implements the Terramate standard error type. It's heavily +influenced by Rob Pike `errors` package in the Upspin project: + + https://commandcenter.blogspot.com/2017/12/error-handling-in-upspin.html + +func As(err error, target interface{}) bool +func HasCode(err error, code Kind) bool +func Is(err, target error) bool +func IsAnyKind(err error, kinds ...Kind) bool +func IsKind(err error, k Kind) bool +type DetailedError struct{ ... } + func D(format string, a ...any) *DetailedError +type Error struct{ ... } + func E(args ...interface{}) *Error +type ErrorDetails struct{ ... } +type Kind string + const ErrInternal Kind = "terramate internal error" +type List struct{ ... } + func L(errs ...error) *List +EOT + + filename = "${path.module}/mock-errors.ignore" +} diff --git a/errors/errlog/_test_mock.tf b/errors/errlog/_test_mock.tf new file mode 100644 index 000000000..0bd7050ea --- /dev/null +++ b/errors/errlog/_test_mock.tf @@ -0,0 +1,14 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "errlog" { + content = <<-EOT +package errlog // import "github.com/terramate-io/terramate/errors/errlog" + +Package errlog provides functions to log Terramate errors nicely and in a +consistent manner. + +func Warn(logger zerolog.Logger, err error, args ...any) +EOT + + filename = "${path.module}/mock-errlog.ignore" +} diff --git a/errors/errlog/stack.tm.hcl b/errors/errlog/stack.tm.hcl new file mode 100644 index 000000000..0c250c9dd --- /dev/null +++ b/errors/errlog/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package errlog // import \"github.com/terramate-io/terramate/errors/errlog\"" + description = "package errlog // import \"github.com/terramate-io/terramate/errors/errlog\"\n\nPackage errlog provides functions to log Terramate errors nicely and in a\nconsistent manner.\n\nfunc Warn(logger zerolog.Logger, err error, args ...any)" + tags = ["errlog", "errors", "golang"] + id = "3d33d880-eef2-4aaa-9a85-f7bdab8d0be8" +} diff --git a/errors/stack.tm.hcl b/errors/stack.tm.hcl new file mode 100644 index 000000000..a23cbba7a --- /dev/null +++ b/errors/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package errors // import \"github.com/terramate-io/terramate/errors\"" + description = "package errors // import \"github.com/terramate-io/terramate/errors\"\n\nPackage errors implements the Terramate standard error type. It's heavily\ninfluenced by Rob Pike `errors` package in the Upspin project:\n\n https://commandcenter.blogspot.com/2017/12/error-handling-in-upspin.html\n\nfunc As(err error, target interface{}) bool\nfunc HasCode(err error, code Kind) bool\nfunc Is(err, target error) bool\nfunc IsAnyKind(err error, kinds ...Kind) bool\nfunc IsKind(err error, k Kind) bool\ntype DetailedError struct{ ... }\n func D(format string, a ...any) *DetailedError\ntype Error struct{ ... }\n func E(args ...interface{}) *Error\ntype ErrorDetails struct{ ... }\ntype Kind string\n const ErrInternal Kind = \"terramate internal error\"\ntype List struct{ ... }\n func L(errs ...error) *List" + tags = ["errors", "golang"] + id = "888fde98-5c68-4ac0-8e39-a5e0e6b926cd" +} diff --git a/errors/verbosity/_test_mock.tf b/errors/verbosity/_test_mock.tf new file mode 100644 index 000000000..3cc0eef82 --- /dev/null +++ b/errors/verbosity/_test_mock.tf @@ -0,0 +1,13 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "verbosity" { + content = <<-EOT +package verbosity // import "github.com/terramate-io/terramate/errors/verbosity" + +Package verbosity defines the common Terramate error verbosity levels. + +const V0 int = iota ... +EOT + + filename = "${path.module}/mock-verbosity.ignore" +} diff --git a/errors/verbosity/stack.tm.hcl b/errors/verbosity/stack.tm.hcl new file mode 100644 index 000000000..f96ac62f3 --- /dev/null +++ b/errors/verbosity/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package verbosity // import \"github.com/terramate-io/terramate/errors/verbosity\"" + description = "package verbosity // import \"github.com/terramate-io/terramate/errors/verbosity\"\n\nPackage verbosity defines the common Terramate error verbosity levels.\n\nconst V0 int = iota ..." + tags = ["errors", "golang", "verbosity"] + id = "74ec6e10-bea7-426f-bd3d-aa5cce0f7b5a" +} diff --git a/event/_test_mock.tf b/event/_test_mock.tf new file mode 100644 index 000000000..01b36fd17 --- /dev/null +++ b/event/_test_mock.tf @@ -0,0 +1,17 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "event" { + content = <<-EOT +package event // import "github.com/terramate-io/terramate/event" + +Package event implements a simple event stream and defines all events generated +by different parts of Terramate. + +type Stream[T any] chan T + func NewStream[T any](buffsize int) Stream[T] +type VendorProgress struct{ ... } +type VendorRequest struct{ ... } +EOT + + filename = "${path.module}/mock-event.ignore" +} diff --git a/event/stack.tm.hcl b/event/stack.tm.hcl new file mode 100644 index 000000000..e990f1583 --- /dev/null +++ b/event/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package event // import \"github.com/terramate-io/terramate/event\"" + description = "package event // import \"github.com/terramate-io/terramate/event\"\n\nPackage event implements a simple event stream and defines all events generated\nby different parts of Terramate.\n\ntype Stream[T any] chan T\n func NewStream[T any](buffsize int) Stream[T]\ntype VendorProgress struct{ ... }\ntype VendorRequest struct{ ... }" + tags = ["event", "golang"] + id = "3bef7cce-e755-49c2-ac71-39f7a0e9144f" +} diff --git a/fs/_test_mock.tf b/fs/_test_mock.tf new file mode 100644 index 000000000..4ce7233f3 --- /dev/null +++ b/fs/_test_mock.tf @@ -0,0 +1,17 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "fs" { + content = <<-EOT +package fs // import "github.com/terramate-io/terramate/fs" + +Package fs provides filesystem related functionality. + +func CopyAll(dstdir, srcdir string) error +func CopyDir(destdir, srcdir string, filter CopyFilterFunc) error +func ListTerramateDirs(dir string) ([]string, error) +func ListTerramateFiles(dir string) (filenames []string, err error) +type CopyFilterFunc func(path string, entry os.DirEntry) bool +EOT + + filename = "${path.module}/mock-fs.ignore" +} diff --git a/fs/stack.tm.hcl b/fs/stack.tm.hcl new file mode 100644 index 000000000..09221f983 --- /dev/null +++ b/fs/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package fs // import \"github.com/terramate-io/terramate/fs\"" + description = "package fs // import \"github.com/terramate-io/terramate/fs\"\n\nPackage fs provides filesystem related functionality.\n\nfunc CopyAll(dstdir, srcdir string) error\nfunc CopyDir(destdir, srcdir string, filter CopyFilterFunc) error\nfunc ListTerramateDirs(dir string) ([]string, error)\nfunc ListTerramateFiles(dir string) (filenames []string, err error)\ntype CopyFilterFunc func(path string, entry os.DirEntry) bool" + tags = ["fs", "golang"] + id = "68556dbf-d1d3-47de-a840-f9792dd06fa0" +} diff --git a/generate/_test_mock.tf b/generate/_test_mock.tf new file mode 100644 index 000000000..b0143b87c --- /dev/null +++ b/generate/_test_mock.tf @@ -0,0 +1,24 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "generate" { + content = <<-EOT +package generate // import "github.com/terramate-io/terramate/generate" + +Package generate implements code generation. It includes all available code +generation strategies on Terramate and it also handles outdated code detection +and deletion. + +const ErrLoadingGlobals errors.Kind = "loading globals" ... +func DetectOutdated(root *config.Root, target *config.Tree, vendorDir project.Path) ([]string, error) +func ListGenFiles(root *config.Root, dir string) ([]string, error) +type FailureResult struct{ ... } +type GenFile interface{ ... } +type LoadResult struct{ ... } + func Load(root *config.Root, vendorDir project.Path) ([]LoadResult, error) +type Report struct{ ... } + func Do(root *config.Root, dir project.Path, vendorDir project.Path, ...) Report +type Result struct{ ... } +EOT + + filename = "${path.module}/mock-generate.ignore" +} diff --git a/generate/genfile/_test_mock.tf b/generate/genfile/_test_mock.tf new file mode 100644 index 000000000..e6d62f425 --- /dev/null +++ b/generate/genfile/_test_mock.tf @@ -0,0 +1,17 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "genfile" { + content = <<-EOT +package genfile // import "github.com/terramate-io/terramate/generate/genfile" + +Package genfile implements generate_file code generation. + +const ErrInvalidContentType errors.Kind = "invalid content type" ... +const StackContext = "stack" ... +type File struct{ ... } + func Eval(block hcl.GenFileBlock, cfg *config.Tree, evalctx *eval.Context) (file File, skip bool, err error) + func Load(root *config.Root, st *config.Stack, parentctx *eval.Context, ...) ([]File, error) +EOT + + filename = "${path.module}/mock-genfile.ignore" +} diff --git a/generate/genfile/stack.tm.hcl b/generate/genfile/stack.tm.hcl new file mode 100644 index 000000000..d0676f489 --- /dev/null +++ b/generate/genfile/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package genfile // import \"github.com/terramate-io/terramate/generate/genfile\"" + description = "package genfile // import \"github.com/terramate-io/terramate/generate/genfile\"\n\nPackage genfile implements generate_file code generation.\n\nconst ErrInvalidContentType errors.Kind = \"invalid content type\" ...\nconst StackContext = \"stack\" ...\ntype File struct{ ... }\n func Eval(block hcl.GenFileBlock, cfg *config.Tree, evalctx *eval.Context) (file File, skip bool, err error)\n func Load(root *config.Root, st *config.Stack, parentctx *eval.Context, ...) ([]File, error)" + tags = ["generate", "genfile", "golang"] + id = "f9ecbd56-b4b3-4410-806f-bc412c5e3c36" +} diff --git a/generate/genhcl/_test_mock.tf b/generate/genhcl/_test_mock.tf new file mode 100644 index 000000000..f4bacf108 --- /dev/null +++ b/generate/genhcl/_test_mock.tf @@ -0,0 +1,21 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "genhcl" { + content = <<-EOT +package genhcl // import "github.com/terramate-io/terramate/generate/genhcl" + +Package genhcl implements generate_hcl code generation. + +const HeaderMagic = "TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT" ... +const ErrParsing errors.Kind = "parsing generate_hcl block" ... +func DefaultHeader() string +func Header(comment CommentStyle) string +type CommentStyle int + const SlashComment CommentStyle = iota ... + func CommentStyleFromConfig(tree *config.Tree) CommentStyle +type HCL struct{ ... } + func Load(root *config.Root, st *config.Stack, evalctx *eval.Context, ...) ([]HCL, error) +EOT + + filename = "${path.module}/mock-genhcl.ignore" +} diff --git a/generate/genhcl/stack.tm.hcl b/generate/genhcl/stack.tm.hcl new file mode 100644 index 000000000..67ecaa3b3 --- /dev/null +++ b/generate/genhcl/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package genhcl // import \"github.com/terramate-io/terramate/generate/genhcl\"" + description = "package genhcl // import \"github.com/terramate-io/terramate/generate/genhcl\"\n\nPackage genhcl implements generate_hcl code generation.\n\nconst HeaderMagic = \"TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT\" ...\nconst ErrParsing errors.Kind = \"parsing generate_hcl block\" ...\nfunc DefaultHeader() string\nfunc Header(comment CommentStyle) string\ntype CommentStyle int\n const SlashComment CommentStyle = iota ...\n func CommentStyleFromConfig(tree *config.Tree) CommentStyle\ntype HCL struct{ ... }\n func Load(root *config.Root, st *config.Stack, evalctx *eval.Context, ...) ([]HCL, error)" + tags = ["generate", "genhcl", "golang"] + id = "140a4bdc-6dc0-4d89-9c0b-9c54256345db" +} diff --git a/generate/sharing/_test_mock.tf b/generate/sharing/_test_mock.tf new file mode 100644 index 000000000..f975a7302 --- /dev/null +++ b/generate/sharing/_test_mock.tf @@ -0,0 +1,14 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "sharing" { + content = <<-EOT +package sharing // import "github.com/terramate-io/terramate/generate/sharing" + +Package sharing implements the loading of sharing related blocks. + +type File struct{ ... } + func PrepareFile(root *config.Root, filename string, inputs config.Inputs, ...) (File, error) +EOT + + filename = "${path.module}/mock-sharing.ignore" +} diff --git a/generate/sharing/stack.tm.hcl b/generate/sharing/stack.tm.hcl new file mode 100644 index 000000000..a9f08f13e --- /dev/null +++ b/generate/sharing/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package sharing // import \"github.com/terramate-io/terramate/generate/sharing\"" + description = "package sharing // import \"github.com/terramate-io/terramate/generate/sharing\"\n\nPackage sharing implements the loading of sharing related blocks.\n\ntype File struct{ ... }\n func PrepareFile(root *config.Root, filename string, inputs config.Inputs, ...) (File, error)" + tags = ["generate", "golang", "sharing"] + id = "3c45e985-14d7-4dcf-8054-c07f74210783" +} diff --git a/generate/stack.tm.hcl b/generate/stack.tm.hcl new file mode 100644 index 000000000..76922483f --- /dev/null +++ b/generate/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package generate // import \"github.com/terramate-io/terramate/generate\"" + description = "package generate // import \"github.com/terramate-io/terramate/generate\"\n\nPackage generate implements code generation. It includes all available code\ngeneration strategies on Terramate and it also handles outdated code detection\nand deletion.\n\nconst ErrLoadingGlobals errors.Kind = \"loading globals\" ...\nfunc DetectOutdated(root *config.Root, target *config.Tree, vendorDir project.Path) ([]string, error)\nfunc ListGenFiles(root *config.Root, dir string) ([]string, error)\ntype FailureResult struct{ ... }\ntype GenFile interface{ ... }\ntype LoadResult struct{ ... }\n func Load(root *config.Root, vendorDir project.Path) ([]LoadResult, error)\ntype Report struct{ ... }\n func Do(root *config.Root, dir project.Path, vendorDir project.Path, ...) Report\ntype Result struct{ ... }" + tags = ["generate", "golang"] + id = "bceb4fd1-ea6c-4346-bdbc-4817a80c70ae" +} diff --git a/generate_preview.tm b/generate_preview.tm new file mode 100644 index 000000000..71f403c6e --- /dev/null +++ b/generate_preview.tm @@ -0,0 +1,22 @@ +// Copyright 2023 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +// This file is required by the "preview" script. + +generate_hcl "_test_mock.tf" { + condition = tm_contains(terramate.stack.tags, "golang") + lets { + name = tm_ternary(terramate.stack.path.basename == "/", "terramate", terramate.stack.path.basename) + } + content { + tm_dynamic "resource" { + labels = ["local_file", let.name] + attributes = { + content = <<-EOF + ${terramate.stack.description} + EOF + filename = "${path.module}/mock-${let.name}.ignore" + } + } + } +} diff --git a/git/_test_mock.tf b/git/_test_mock.tf new file mode 100644 index 000000000..15ca899e7 --- /dev/null +++ b/git/_test_mock.tf @@ -0,0 +1,35 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "git" { + content = <<-EOT +package git // import "github.com/terramate-io/terramate/git" + +Package git provides a wrapper for the git command line program. The helper +methods avoids porcelain commands as much as possible and return a parsed output +whenever possible. + +Users of this package have access to the low-level Exec() function for the +methods not yet implemented. + +const ErrInvalidGitURL errors.Kind = "invalid git remote URL" +func IsURL(u string) bool +func NewCmdError(cmd string, stdout, stderr []byte) error +func ParseURL(rawURL string) (u *url.URL, err error) +func RepoInfoFromURL(u *url.URL) (host string, owner string, name string, err error) +type CmdError struct{ ... } +type CommitMetadata struct{ ... } +type Config struct{ ... } +type Error string + const ErrGitNotFound Error = "git program not found" ... +type Git struct{ ... } + func WithConfig(cfg Config) (*Git, error) +type LogLine struct{ ... } +type Options struct{ ... } +type Ref struct{ ... } +type Remote struct{ ... } +type Repository struct{ ... } + func NormalizeGitURI(raw string) (Repository, error) +EOT + + filename = "${path.module}/mock-git.ignore" +} diff --git a/git/stack.tm.hcl b/git/stack.tm.hcl new file mode 100644 index 000000000..aabbd085e --- /dev/null +++ b/git/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package git // import \"github.com/terramate-io/terramate/git\"" + description = "package git // import \"github.com/terramate-io/terramate/git\"\n\nPackage git provides a wrapper for the git command line program. The helper\nmethods avoids porcelain commands as much as possible and return a parsed output\nwhenever possible.\n\nUsers of this package have access to the low-level Exec() function for the\nmethods not yet implemented.\n\nconst ErrInvalidGitURL errors.Kind = \"invalid git remote URL\"\nfunc IsURL(u string) bool\nfunc NewCmdError(cmd string, stdout, stderr []byte) error\nfunc ParseURL(rawURL string) (u *url.URL, err error)\nfunc RepoInfoFromURL(u *url.URL) (host string, owner string, name string, err error)\ntype CmdError struct{ ... }\ntype CommitMetadata struct{ ... }\ntype Config struct{ ... }\ntype Error string\n const ErrGitNotFound Error = \"git program not found\" ...\ntype Git struct{ ... }\n func WithConfig(cfg Config) (*Git, error)\ntype LogLine struct{ ... }\ntype Options struct{ ... }\ntype Ref struct{ ... }\ntype Remote struct{ ... }\ntype Repository struct{ ... }\n func NormalizeGitURI(raw string) (Repository, error)" + tags = ["git", "golang"] + id = "04c83acd-c138-4b51-bd77-d342b0209780" +} diff --git a/globals/_test_mock.tf b/globals/_test_mock.tf new file mode 100644 index 000000000..feda90001 --- /dev/null +++ b/globals/_test_mock.tf @@ -0,0 +1,25 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "globals" { + content = <<-EOT +package globals // import "github.com/terramate-io/terramate/globals" + +Package globals provides functions for loading globals. + +const ErrEval errors.Kind = "global eval" ... +type EvalError struct{ ... } +type EvalReport struct{ ... } + func ForDir(root *config.Root, cfgdir project.Path, ctx *eval.Context) EvalReport + func ForStack(root *config.Root, stack *config.Stack) EvalReport + func NewEvalReport() EvalReport +type Expr struct{ ... } +type ExprSet struct{ ... } +type GlobalPathKey struct{ ... } + func NewGlobalAttrPath(basepath []string, name string) GlobalPathKey + func NewGlobalExtendPath(path []string) GlobalPathKey +type HierarchicalExprs map[project.Path]*ExprSet + func LoadExprs(tree *config.Tree) (HierarchicalExprs, error) +EOT + + filename = "${path.module}/mock-globals.ignore" +} diff --git a/globals/stack.tm.hcl b/globals/stack.tm.hcl new file mode 100644 index 000000000..b34a9d070 --- /dev/null +++ b/globals/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package globals // import \"github.com/terramate-io/terramate/globals\"" + description = "package globals // import \"github.com/terramate-io/terramate/globals\"\n\nPackage globals provides functions for loading globals.\n\nconst ErrEval errors.Kind = \"global eval\" ...\ntype EvalError struct{ ... }\ntype EvalReport struct{ ... }\n func ForDir(root *config.Root, cfgdir project.Path, ctx *eval.Context) EvalReport\n func ForStack(root *config.Root, stack *config.Stack) EvalReport\n func NewEvalReport() EvalReport\ntype Expr struct{ ... }\ntype ExprSet struct{ ... }\ntype GlobalPathKey struct{ ... }\n func NewGlobalAttrPath(basepath []string, name string) GlobalPathKey\n func NewGlobalExtendPath(path []string) GlobalPathKey\ntype HierarchicalExprs map[project.Path]*ExprSet\n func LoadExprs(tree *config.Tree) (HierarchicalExprs, error)" + tags = ["globals", "golang"] + id = "4a34f564-d4a0-47e0-9dd7-75360f7e7af2" +} diff --git a/golangci.tm b/golangci.tm index 239e0d3f6..4f022abf2 100644 --- a/golangci.tm +++ b/golangci.tm @@ -18,7 +18,7 @@ generate_file "/.golangci.toml" { "exclude-rules" = [ { path = "(.+)_test\\.go" - text = "dot-imports:" + text = "dot-imports:" linters = ["revive"] } ] diff --git a/hack/check-stacks.sh b/hack/check-stacks.sh new file mode 100755 index 000000000..f91b568b3 --- /dev/null +++ b/hack/check-stacks.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# Copyright 2024 Terramate GmbH +# SPDX-License-Identifier: MPL-2.0 + + +source "$(dirname "$0")/packages.sh" + +rootdir=$(git rev-parse --show-toplevel) + +for pkg in $(packages_with_tests); do + cd $pkg + projdir=${pkg#"$rootdir"} + if [ "x${projdir}" == "x" ]; then + projdir="/" + fi + if ! test -f stack.tm -o -f stack.tm.hcl; then + echo "Stack ${projdir} must be created! Please run ./hack/create-stacks.sh" + exit 1 + fi +done diff --git a/hack/create-stacks.sh b/hack/create-stacks.sh new file mode 100755 index 000000000..6dc0c5f8a --- /dev/null +++ b/hack/create-stacks.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# Copyright 2024 Terramate GmbH +# SPDX-License-Identifier: MPL-2.0 + + +source "$(dirname "$0")/packages.sh" + +rootdir=$(git rev-parse --show-toplevel) + +for pkg in $(packages_with_tests); do + cd $pkg + projdir=${pkg#"$rootdir"} + if [ "x${projdir}" == "x" ]; then + projdir="/" + fi + if test -f stack.tm -o -f stack.tm.hcl; then + continue + fi + name=$(go doc . | head -n1) + desc=$(go doc .) + tags=$(terramate experimental eval 'tm_join(",", tm_distinct([for p in tm_split("/", "'$projdir'") : p if p != ""]))') + if ! test -z $tags; then + tags="--tags=golang,${tags}" + else + tags="--tags=golang" + fi + terramate create . \ + --name="$name" \ + --description="$desc" \ + $tags +done diff --git a/hack/packages.sh b/hack/packages.sh new file mode 100644 index 000000000..faf7c8273 --- /dev/null +++ b/hack/packages.sh @@ -0,0 +1,10 @@ +# Copyright 2024 Terramate GmbH +# SPDX-License-Identifier: MPL-2.0 + +packages() { + go list -f '{{.Dir}}' ./... | sort +} + +packages_with_tests() { + go list -f '{{.Dir}}' ./... | sort +} diff --git a/hcl/_test_mock.tf b/hcl/_test_mock.tf new file mode 100644 index 000000000..11d2005c3 --- /dev/null +++ b/hcl/_test_mock.tf @@ -0,0 +1,72 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "hcl" { + content = <<-EOT +package hcl // import "github.com/terramate-io/terramate/hcl" + +Package hcl provides parsing functionality for Terramate HCL configuration. +It also provides printing and formatting for Terramate configuration. + +const ErrHCLSyntax errors.Kind = "HCL syntax error" ... +const ErrScriptNoLabels errors.Kind = "terramate schema error: (script): must provide at least one label" ... +const SharingIsCaringExperimentName = "outputs-sharing" +const StackBlockType = "stack" +func IsRootConfig(rootdir string) (bool, error) +func MatchAnyGlob(globs []glob.Glob, s string) bool +func PrintConfig(w io.Writer, cfg Config) error +func PrintImports(w io.Writer, imports []string) error +func ValueAsStringList(val cty.Value) ([]string, error) +type AssertConfig struct{ ... } +type ChangeDetectionConfig struct{ ... } +type CloudConfig struct{ ... } +type Command ast.Attribute + func NewScriptCommand(attr ast.Attribute) *Command +type Commands ast.Attribute + func NewScriptCommands(attr ast.Attribute) *Commands +type Config struct{ ... } + func NewConfig(dir string) (Config, error) + func ParseDir(root string, dir string, experiments ...string) (Config, error) +type Evaluator interface{ ... } +type GenFileBlock struct{ ... } +type GenHCLBlock struct{ ... } +type GenerateConfig struct{ ... } +type GenerateRootConfig struct{ ... } +type GitConfig struct{ ... } + func NewGitConfig() *GitConfig +type Input struct{ ... } +type Inputs []Input +type ManifestConfig struct{ ... } +type ManifestDesc struct{ ... } +type OptionalCheck int + const CheckIsUnset OptionalCheck = iota ... + func ToOptionalCheck(v bool) OptionalCheck +type Output struct{ ... } +type Outputs []Output +type RawConfig struct{ ... } + func NewCustomRawConfig(handlers map[string]mergeHandler) RawConfig + func NewTopLevelRawConfig() RawConfig +type RootConfig struct{ ... } +type RunConfig struct{ ... } + func NewRunConfig() *RunConfig +type RunEnv struct{ ... } +type Script struct{ ... } +type ScriptJob struct{ ... } +type SharingBackend struct{ ... } +type SharingBackendType int + const TerraformSharingBackend SharingBackendType = iota + 1 +type SharingBackends []SharingBackend +type Stack struct{ ... } +type StackFilterConfig struct{ ... } +type TargetsConfig struct{ ... } +type TerragruntChangeDetectionEnabledOption int + const TerragruntAutoOption TerragruntChangeDetectionEnabledOption = iota ... +type TerragruntConfig struct{ ... } +type Terramate struct{ ... } +type TerramateParser struct{ ... } + func NewStrictTerramateParser(rootdir string, dir string, experiments ...string) (*TerramateParser, error) + func NewTerramateParser(rootdir string, dir string, experiments ...string) (*TerramateParser, error) +type VendorConfig struct{ ... } +EOT + + filename = "${path.module}/mock-hcl.ignore" +} diff --git a/hcl/ast/_test_mock.tf b/hcl/ast/_test_mock.tf new file mode 100644 index 000000000..77de8bfcc --- /dev/null +++ b/hcl/ast/_test_mock.tf @@ -0,0 +1,37 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "ast" { + content = <<-EOT +package ast // import "github.com/terramate-io/terramate/hcl/ast" + +Package ast provides low level parsing facilities for HCL configuration. +It includes extra features like block merging, specific to Terramate needs. + +func AsHCLAttributes(syntaxAttrs hclsyntax.Attributes) hhcl.Attributes +func CloneExpr(expr hclsyntax.Expression) hclsyntax.Expression +func ParseExpression(str string, filename string) (hcl.Expression, error) +func SortRawAttributes(attrs hhcl.Attributes) []*hhcl.Attribute +func TokensForExpression(expr hcl.Expression) hclwrite.Tokens +func TokensForValue(value cty.Value) hclwrite.Tokens +type Attribute struct{ ... } + func NewAttribute(rootdir string, val *hhcl.Attribute) Attribute +type AttributeSlice []Attribute +type Attributes map[string]Attribute + func NewAttributes(rootdir string, rawAttrs hhcl.Attributes) Attributes +type Block struct{ ... } + func NewBlock(rootdir string, block *hclsyntax.Block) *Block +type BlockType string +type Blocks []*Block + func NewBlocks(rootdir string, rawblocks hclsyntax.Blocks) Blocks +type CloneExpression struct{ ... } +type LabelBlockType struct{ ... } + func NewEmptyLabelBlockType(typ string) LabelBlockType + func NewLabelBlockType(typ string, labels []string) (LabelBlockType, error) +type MergedBlock struct{ ... } + func NewMergedBlock(typ string, labels []string) *MergedBlock +type MergedBlocks map[string]*MergedBlock +type MergedLabelBlocks map[LabelBlockType]*MergedBlock +EOT + + filename = "${path.module}/mock-ast.ignore" +} diff --git a/hcl/ast/stack.tm.hcl b/hcl/ast/stack.tm.hcl new file mode 100644 index 000000000..4d44ed569 --- /dev/null +++ b/hcl/ast/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package ast // import \"github.com/terramate-io/terramate/hcl/ast\"" + description = "package ast // import \"github.com/terramate-io/terramate/hcl/ast\"\n\nPackage ast provides low level parsing facilities for HCL configuration.\nIt includes extra features like block merging, specific to Terramate needs.\n\nfunc AsHCLAttributes(syntaxAttrs hclsyntax.Attributes) hhcl.Attributes\nfunc CloneExpr(expr hclsyntax.Expression) hclsyntax.Expression\nfunc ParseExpression(str string, filename string) (hcl.Expression, error)\nfunc SortRawAttributes(attrs hhcl.Attributes) []*hhcl.Attribute\nfunc TokensForExpression(expr hcl.Expression) hclwrite.Tokens\nfunc TokensForValue(value cty.Value) hclwrite.Tokens\ntype Attribute struct{ ... }\n func NewAttribute(rootdir string, val *hhcl.Attribute) Attribute\ntype AttributeSlice []Attribute\ntype Attributes map[string]Attribute\n func NewAttributes(rootdir string, rawAttrs hhcl.Attributes) Attributes\ntype Block struct{ ... }\n func NewBlock(rootdir string, block *hclsyntax.Block) *Block\ntype BlockType string\ntype Blocks []*Block\n func NewBlocks(rootdir string, rawblocks hclsyntax.Blocks) Blocks\ntype CloneExpression struct{ ... }\ntype LabelBlockType struct{ ... }\n func NewEmptyLabelBlockType(typ string) LabelBlockType\n func NewLabelBlockType(typ string, labels []string) (LabelBlockType, error)\ntype MergedBlock struct{ ... }\n func NewMergedBlock(typ string, labels []string) *MergedBlock\ntype MergedBlocks map[string]*MergedBlock\ntype MergedLabelBlocks map[LabelBlockType]*MergedBlock" + tags = ["ast", "golang", "hcl"] + id = "d4394e8f-4dfc-4d46-b5a5-a1edea55fab4" +} diff --git a/hcl/eval/_test_mock.tf b/hcl/eval/_test_mock.tf new file mode 100644 index 000000000..60291b76b --- /dev/null +++ b/hcl/eval/_test_mock.tf @@ -0,0 +1,26 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "eval" { + content = <<-EOT +package eval // import "github.com/terramate-io/terramate/hcl/eval" + +Package eval provides both full and partial evaluation of HCL. + +const ErrPartial errors.Kind = "partial evaluation failed" ... +const ErrCannotExtendObject errors.Kind = "cannot extend object" +const ErrEval errors.Kind = "eval expression" +type Context struct{ ... } + func NewContext(funcs map[string]function.Function) *Context + func NewContextFrom(ctx *hhcl.EvalContext) *Context +type CtyValue struct{ ... } + func NewCtyValue(val cty.Value, origin Info) CtyValue +type Info struct{ ... } +type Object struct{ ... } + func NewObject(origin Info) *Object +type ObjectPath []string +type Value interface{ ... } + func NewValue(val cty.Value, origin Info) Value +EOT + + filename = "${path.module}/mock-eval.ignore" +} diff --git a/hcl/eval/stack.tm.hcl b/hcl/eval/stack.tm.hcl new file mode 100644 index 000000000..00b1a9501 --- /dev/null +++ b/hcl/eval/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package eval // import \"github.com/terramate-io/terramate/hcl/eval\"" + description = "package eval // import \"github.com/terramate-io/terramate/hcl/eval\"\n\nPackage eval provides both full and partial evaluation of HCL.\n\nconst ErrPartial errors.Kind = \"partial evaluation failed\" ...\nconst ErrCannotExtendObject errors.Kind = \"cannot extend object\"\nconst ErrEval errors.Kind = \"eval expression\"\ntype Context struct{ ... }\n func NewContext(funcs map[string]function.Function) *Context\n func NewContextFrom(ctx *hhcl.EvalContext) *Context\ntype CtyValue struct{ ... }\n func NewCtyValue(val cty.Value, origin Info) CtyValue\ntype Info struct{ ... }\ntype Object struct{ ... }\n func NewObject(origin Info) *Object\ntype ObjectPath []string\ntype Value interface{ ... }\n func NewValue(val cty.Value, origin Info) Value" + tags = ["eval", "golang", "hcl"] + id = "5d3518ee-f9fa-414c-a446-e2d134e43239" +} diff --git a/hcl/fmt/_test_mock.tf b/hcl/fmt/_test_mock.tf new file mode 100644 index 000000000..20840e862 --- /dev/null +++ b/hcl/fmt/_test_mock.tf @@ -0,0 +1,20 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "fmt" { + content = <<-EOT +package fmt // import "github.com/terramate-io/terramate/hcl/fmt" + +Package fmt contains functions for formatting hcl config. + +const ErrHCLSyntax errors.Kind = "HCL syntax error" +const ErrReadFile errors.Kind = "failed to read file" +func Format(src, filename string) (string, error) +func FormatAttributes(attrs map[string]cty.Value) string +func FormatMultiline(src, filename string) (string, error) +type FormatResult struct{ ... } + func FormatFiles(basedir string, files []string) ([]FormatResult, error) + func FormatTree(dir string) ([]FormatResult, error) +EOT + + filename = "${path.module}/mock-fmt.ignore" +} diff --git a/hcl/fmt/stack.tm.hcl b/hcl/fmt/stack.tm.hcl new file mode 100644 index 000000000..462081423 --- /dev/null +++ b/hcl/fmt/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package fmt // import \"github.com/terramate-io/terramate/hcl/fmt\"" + description = "package fmt // import \"github.com/terramate-io/terramate/hcl/fmt\"\n\nPackage fmt contains functions for formatting hcl config.\n\nconst ErrHCLSyntax errors.Kind = \"HCL syntax error\"\nconst ErrReadFile errors.Kind = \"failed to read file\"\nfunc Format(src, filename string) (string, error)\nfunc FormatAttributes(attrs map[string]cty.Value) string\nfunc FormatMultiline(src, filename string) (string, error)\ntype FormatResult struct{ ... }\n func FormatFiles(basedir string, files []string) ([]FormatResult, error)\n func FormatTree(dir string) ([]FormatResult, error)" + tags = ["fmt", "golang", "hcl"] + id = "4c9c3934-72bb-4520-90c9-89de1dff254b" +} diff --git a/hcl/info/_test_mock.tf b/hcl/info/_test_mock.tf new file mode 100644 index 000000000..2f724a794 --- /dev/null +++ b/hcl/info/_test_mock.tf @@ -0,0 +1,17 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "info" { + content = <<-EOT +package info // import "github.com/terramate-io/terramate/hcl/info" + +Package info provides informational types related to hcl. + +type Pos struct{ ... } + func NewPos(p hcl.Pos) Pos +type Range struct{ ... } + func NewRange(rootdir string, r hcl.Range) Range +type Ranges []Range +EOT + + filename = "${path.module}/mock-info.ignore" +} diff --git a/hcl/info/stack.tm.hcl b/hcl/info/stack.tm.hcl new file mode 100644 index 000000000..23194c24a --- /dev/null +++ b/hcl/info/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package info // import \"github.com/terramate-io/terramate/hcl/info\"" + description = "package info // import \"github.com/terramate-io/terramate/hcl/info\"\n\nPackage info provides informational types related to hcl.\n\ntype Pos struct{ ... }\n func NewPos(p hcl.Pos) Pos\ntype Range struct{ ... }\n func NewRange(rootdir string, r hcl.Range) Range\ntype Ranges []Range" + tags = ["golang", "hcl", "info"] + id = "ed8a764a-e3bb-4811-8677-ce125db06359" +} diff --git a/hcl/stack.tm.hcl b/hcl/stack.tm.hcl new file mode 100644 index 000000000..d08c1b81d --- /dev/null +++ b/hcl/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package hcl // import \"github.com/terramate-io/terramate/hcl\"" + description = "package hcl // import \"github.com/terramate-io/terramate/hcl\"\n\nPackage hcl provides parsing functionality for Terramate HCL configuration.\nIt also provides printing and formatting for Terramate configuration.\n\nconst ErrHCLSyntax errors.Kind = \"HCL syntax error\" ...\nconst ErrScriptNoLabels errors.Kind = \"terramate schema error: (script): must provide at least one label\" ...\nconst SharingIsCaringExperimentName = \"outputs-sharing\"\nconst StackBlockType = \"stack\"\nfunc IsRootConfig(rootdir string) (bool, error)\nfunc MatchAnyGlob(globs []glob.Glob, s string) bool\nfunc PrintConfig(w io.Writer, cfg Config) error\nfunc PrintImports(w io.Writer, imports []string) error\nfunc ValueAsStringList(val cty.Value) ([]string, error)\ntype AssertConfig struct{ ... }\ntype ChangeDetectionConfig struct{ ... }\ntype CloudConfig struct{ ... }\ntype Command ast.Attribute\n func NewScriptCommand(attr ast.Attribute) *Command\ntype Commands ast.Attribute\n func NewScriptCommands(attr ast.Attribute) *Commands\ntype Config struct{ ... }\n func NewConfig(dir string) (Config, error)\n func ParseDir(root string, dir string, experiments ...string) (Config, error)\ntype Evaluator interface{ ... }\ntype GenFileBlock struct{ ... }\ntype GenHCLBlock struct{ ... }\ntype GenerateConfig struct{ ... }\ntype GenerateRootConfig struct{ ... }\ntype GitConfig struct{ ... }\n func NewGitConfig() *GitConfig\ntype Input struct{ ... }\ntype Inputs []Input\ntype ManifestConfig struct{ ... }\ntype ManifestDesc struct{ ... }\ntype OptionalCheck int\n const CheckIsUnset OptionalCheck = iota ...\n func ToOptionalCheck(v bool) OptionalCheck\ntype Output struct{ ... }\ntype Outputs []Output\ntype RawConfig struct{ ... }\n func NewCustomRawConfig(handlers map[string]mergeHandler) RawConfig\n func NewTopLevelRawConfig() RawConfig\ntype RootConfig struct{ ... }\ntype RunConfig struct{ ... }\n func NewRunConfig() *RunConfig\ntype RunEnv struct{ ... }\ntype Script struct{ ... }\ntype ScriptJob struct{ ... }\ntype SharingBackend struct{ ... }\ntype SharingBackendType int\n const TerraformSharingBackend SharingBackendType = iota + 1\ntype SharingBackends []SharingBackend\ntype Stack struct{ ... }\ntype StackFilterConfig struct{ ... }\ntype TargetsConfig struct{ ... }\ntype TerragruntChangeDetectionEnabledOption int\n const TerragruntAutoOption TerragruntChangeDetectionEnabledOption = iota ...\ntype TerragruntConfig struct{ ... }\ntype Terramate struct{ ... }\ntype TerramateParser struct{ ... }\n func NewStrictTerramateParser(rootdir string, dir string, experiments ...string) (*TerramateParser, error)\n func NewTerramateParser(rootdir string, dir string, experiments ...string) (*TerramateParser, error)\ntype VendorConfig struct{ ... }" + tags = ["golang", "hcl"] + id = "dd11014a-a1bb-4f1c-99da-8f6d188d36d1" +} diff --git a/lets/_test_mock.tf b/lets/_test_mock.tf new file mode 100644 index 000000000..a52fdeebe --- /dev/null +++ b/lets/_test_mock.tf @@ -0,0 +1,18 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "lets" { + content = <<-EOT +package lets // import "github.com/terramate-io/terramate/lets" + +Package lets provides parsing and evaluation of lets blocks. + +const ErrEval errors.Kind = "lets eval" ... +func Load(letblock *ast.MergedBlock, ctx *eval.Context) error +type Expr struct{ ... } +type Exprs map[string]Expr +type Map map[string]Value +type Value struct{ ... } +EOT + + filename = "${path.module}/mock-lets.ignore" +} diff --git a/lets/stack.tm.hcl b/lets/stack.tm.hcl new file mode 100644 index 000000000..b317726ca --- /dev/null +++ b/lets/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package lets // import \"github.com/terramate-io/terramate/lets\"" + description = "package lets // import \"github.com/terramate-io/terramate/lets\"\n\nPackage lets provides parsing and evaluation of lets blocks.\n\nconst ErrEval errors.Kind = \"lets eval\" ...\nfunc Load(letblock *ast.MergedBlock, ctx *eval.Context) error\ntype Expr struct{ ... }\ntype Exprs map[string]Expr\ntype Map map[string]Value\ntype Value struct{ ... }" + tags = ["golang", "lets"] + id = "a9c2b782-c3ee-4930-ace1-e20ca045df86" +} diff --git a/ls/_test_mock.tf b/ls/_test_mock.tf new file mode 100644 index 000000000..7a7600cd5 --- /dev/null +++ b/ls/_test_mock.tf @@ -0,0 +1,17 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "ls" { + content = <<-EOT +package tmls // import "github.com/terramate-io/terramate/ls" + +Package tmls implements a Terramate Language Server (LSP). + +const ErrUnrecognizedCommand errors.Kind = "terramate-ls: unknown command" ... +const MethodExecuteCommand = "workspace/executeCommand" +type Server struct{ ... } + func NewServer(conn jsonrpc2.Conn) *Server + func ServerWithLogger(conn jsonrpc2.Conn, l zerolog.Logger) *Server +EOT + + filename = "${path.module}/mock-ls.ignore" +} diff --git a/ls/stack.tm.hcl b/ls/stack.tm.hcl new file mode 100644 index 000000000..41d3df55b --- /dev/null +++ b/ls/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package tmls // import \"github.com/terramate-io/terramate/ls\"" + description = "package tmls // import \"github.com/terramate-io/terramate/ls\"\n\nPackage tmls implements a Terramate Language Server (LSP).\n\nconst ErrUnrecognizedCommand errors.Kind = \"terramate-ls: unknown command\" ...\nconst MethodExecuteCommand = \"workspace/executeCommand\"\ntype Server struct{ ... }\n func NewServer(conn jsonrpc2.Conn) *Server\n func ServerWithLogger(conn jsonrpc2.Conn, l zerolog.Logger) *Server" + tags = ["golang", "ls"] + id = "adaa9d27-4d58-4fa9-a160-a8e92ee70db6" +} diff --git a/makefiles/common.mk b/makefiles/common.mk index f297656ec..4f52c75d0 100644 --- a/makefiles/common.mk +++ b/makefiles/common.mk @@ -1,7 +1,7 @@ GO_RELEASER_VERSION=v1.14.0 GOLANGCI_LINT_VERSION ?= v1.60.3 COVERAGE_REPORT ?= coverage.txt -RUN_ADD_LICENSE=go run github.com/google/addlicense@v1.0.0 -l mpl -s=only -ignore 'docs/**' +RUN_ADD_LICENSE=go run github.com/google/addlicense@v1.0.0 -l mpl -s=only -ignore 'docs/**' -ignore '**/*.tf' BENCH_CHECK=go run github.com/madlambda/benchcheck/cmd/benchcheck@743137fbfd827958b25ab6b13fa1180e0e933eb1 ## Build terramate tools into bin directory @@ -56,7 +56,7 @@ fmt: ## lint code .PHONY: lint lint: - go run github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run ./... + go run github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) run . ## tidy up go modules .PHONY: mod diff --git a/makefiles/unix.mk b/makefiles/unix.mk index 16281e46f..f031b180d 100644 --- a/makefiles/unix.mk +++ b/makefiles/unix.mk @@ -41,6 +41,20 @@ test: test/helper build TM_TEST_ROOT_TEMPDIR=$(tempdir) ./bin/terramate run --no-recursive -- go test -race -count=1 -timeout 30m ./... ./bin/helper rm $(tempdir) +## test/sync code +.PHONY: test/sync +tempdir=$(shell ./bin/helper tempdir) +test/sync: test/helper build +# Using `terramate` because it detects and fails if the generated files are outdated. + TMC_API_HOST=api.stg.terramate.io \ + TM_TEST_ROOT_TEMPDIR=$(tempdir) \ + TM_CLOUD_ORGANIZATION=test \ + GITHUB_TOKEN=$(shell cat ../my_github_token.txt) \ + NO_COLOR=1 \ + CI=1 \ + ./bin/terramate script run --tags golang --parallel=10 preview + ./bin/helper rm $(tempdir) + ## test/interop .PHONY: test/interop test/interop: org?=test @@ -54,11 +68,6 @@ graph2png: ./bin/terramate experimental run-graph | dot -Tpng > graph.png @echo "check the image: graph.png" -## test if terramate works with CI git environment. -.PHONY: test/ci -test/ci: build - ./bin/terramate list --changed - ## check go modules are tidy .PHONY: mod/check mod/check: diff --git a/mapexpr/_test_mock.tf b/mapexpr/_test_mock.tf new file mode 100644 index 000000000..024d34e5e --- /dev/null +++ b/mapexpr/_test_mock.tf @@ -0,0 +1,15 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "mapexpr" { + content = <<-EOT +package mapexpr // import "github.com/terramate-io/terramate/mapexpr" + +Package mapexpr implements the `map` block as an HCL expression type. + +type Attributes struct{ ... } +type MapExpr struct{ ... } + func NewMapExpr(block *ast.MergedBlock) (*MapExpr, error) +EOT + + filename = "${path.module}/mock-mapexpr.ignore" +} diff --git a/mapexpr/stack.tm.hcl b/mapexpr/stack.tm.hcl new file mode 100644 index 000000000..96e52765b --- /dev/null +++ b/mapexpr/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package mapexpr // import \"github.com/terramate-io/terramate/mapexpr\"" + description = "package mapexpr // import \"github.com/terramate-io/terramate/mapexpr\"\n\nPackage mapexpr implements the `map` block as an HCL expression type.\n\ntype Attributes struct{ ... }\ntype MapExpr struct{ ... }\n func NewMapExpr(block *ast.MergedBlock) (*MapExpr, error)" + tags = ["golang", "mapexpr"] + id = "310fef29-9926-4f93-b104-79ff67203f75" +} diff --git a/mapexpr/test/_test_mock.tf b/mapexpr/test/_test_mock.tf new file mode 100644 index 000000000..3cff8a1fb --- /dev/null +++ b/mapexpr/test/_test_mock.tf @@ -0,0 +1,14 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "test" { + content = <<-EOT +package test // import "github.com/terramate-io/terramate/mapexpr/test" + +Package test implements testcases and test helpers for dealing with map blocks. + +type Testcase struct{ ... } + func SchemaErrorTestcases() []Testcase +EOT + + filename = "${path.module}/mock-test.ignore" +} diff --git a/mapexpr/test/stack.tm.hcl b/mapexpr/test/stack.tm.hcl new file mode 100644 index 000000000..bd4e8df1b --- /dev/null +++ b/mapexpr/test/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package test // import \"github.com/terramate-io/terramate/mapexpr/test\"" + description = "package test // import \"github.com/terramate-io/terramate/mapexpr/test\"\n\nPackage test implements testcases and test helpers for dealing with map blocks.\n\ntype Testcase struct{ ... }\n func SchemaErrorTestcases() []Testcase" + tags = ["golang", "mapexpr", "test"] + id = "5369bac2-d63d-4b74-b270-af07e2fd25b9" +} diff --git a/modvendor/_test_mock.tf b/modvendor/_test_mock.tf new file mode 100644 index 000000000..ed40ab7c5 --- /dev/null +++ b/modvendor/_test_mock.tf @@ -0,0 +1,16 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "modvendor" { + content = <<-EOT +package modvendor // import "github.com/terramate-io/terramate/modvendor" + +Package modvendor provides basic functions and types to support Terraform module +vendoring. + +func AbsVendorDir(rootdir string, vendorDir project.Path, modsrc tf.Source) string +func SourceDir(path string, rootdir string, vendordir project.Path) string +func TargetDir(vendorDir project.Path, modsrc tf.Source) project.Path +EOT + + filename = "${path.module}/mock-modvendor.ignore" +} diff --git a/modvendor/download/_test_mock.tf b/modvendor/download/_test_mock.tf new file mode 100644 index 000000000..664ab2d4b --- /dev/null +++ b/modvendor/download/_test_mock.tf @@ -0,0 +1,23 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "download" { + content = <<-EOT +package download // import "github.com/terramate-io/terramate/modvendor/download" + +Package download is responsible for downloading vendored modules. + +const ErrAlreadyVendored errors.Kind = "module is already vendored" ... +func HandleVendorRequests(rootdir string, vendorRequests <-chan event.VendorRequest, ...) <-chan Report +func MergeVendorReports(reports <-chan Report) <-chan Report +type IgnoredVendor struct{ ... } +type ProgressEventStream event.Stream[event.VendorProgress] + func NewEventStream() ProgressEventStream +type Report struct{ ... } + func NewReport(vendordir project.Path) Report + func Vendor(rootdir string, vendorDir project.Path, modsrc tf.Source, ...) Report + func VendorAll(rootdir string, vendorDir project.Path, tfdir string, ...) Report +type Vendored struct{ ... } +EOT + + filename = "${path.module}/mock-download.ignore" +} diff --git a/modvendor/download/stack.tm.hcl b/modvendor/download/stack.tm.hcl new file mode 100644 index 000000000..a847aa666 --- /dev/null +++ b/modvendor/download/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package download // import \"github.com/terramate-io/terramate/modvendor/download\"" + description = "package download // import \"github.com/terramate-io/terramate/modvendor/download\"\n\nPackage download is responsible for downloading vendored modules.\n\nconst ErrAlreadyVendored errors.Kind = \"module is already vendored\" ...\nfunc HandleVendorRequests(rootdir string, vendorRequests <-chan event.VendorRequest, ...) <-chan Report\nfunc MergeVendorReports(reports <-chan Report) <-chan Report\ntype IgnoredVendor struct{ ... }\ntype ProgressEventStream event.Stream[event.VendorProgress]\n func NewEventStream() ProgressEventStream\ntype Report struct{ ... }\n func NewReport(vendordir project.Path) Report\n func Vendor(rootdir string, vendorDir project.Path, modsrc tf.Source, ...) Report\n func VendorAll(rootdir string, vendorDir project.Path, tfdir string, ...) Report\ntype Vendored struct{ ... }" + tags = ["download", "golang", "modvendor"] + id = "8037655d-1451-44a8-84aa-be1b4f2a4e7d" +} diff --git a/modvendor/manifest/_test_mock.tf b/modvendor/manifest/_test_mock.tf new file mode 100644 index 000000000..085ad2426 --- /dev/null +++ b/modvendor/manifest/_test_mock.tf @@ -0,0 +1,13 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "manifest" { + content = <<-EOT +package manifest // import "github.com/terramate-io/terramate/modvendor/manifest" + +Package manifest implements vendor manifest parsing. + +func LoadFileMatcher(rootdir string) (gitignore.Matcher, error) +EOT + + filename = "${path.module}/mock-manifest.ignore" +} diff --git a/modvendor/manifest/stack.tm.hcl b/modvendor/manifest/stack.tm.hcl new file mode 100644 index 000000000..90a481c24 --- /dev/null +++ b/modvendor/manifest/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package manifest // import \"github.com/terramate-io/terramate/modvendor/manifest\"" + description = "package manifest // import \"github.com/terramate-io/terramate/modvendor/manifest\"\n\nPackage manifest implements vendor manifest parsing.\n\nfunc LoadFileMatcher(rootdir string) (gitignore.Matcher, error)" + tags = ["golang", "manifest", "modvendor"] + id = "146789a2-dbab-4938-a1f0-0dd21fe94fa8" +} diff --git a/modvendor/stack.tm.hcl b/modvendor/stack.tm.hcl new file mode 100644 index 000000000..0094f5c5b --- /dev/null +++ b/modvendor/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package modvendor // import \"github.com/terramate-io/terramate/modvendor\"" + description = "package modvendor // import \"github.com/terramate-io/terramate/modvendor\"\n\nPackage modvendor provides basic functions and types to support Terraform module\nvendoring.\n\nfunc AbsVendorDir(rootdir string, vendorDir project.Path, modsrc tf.Source) string\nfunc SourceDir(path string, rootdir string, vendordir project.Path) string\nfunc TargetDir(vendorDir project.Path, modsrc tf.Source) project.Path" + tags = ["golang", "modvendor"] + id = "2ca96d4e-828c-4f90-b67e-203f363c63a7" +} diff --git a/printer/_test_mock.tf b/printer/_test_mock.tf new file mode 100644 index 000000000..bef65c11f --- /dev/null +++ b/printer/_test_mock.tf @@ -0,0 +1,17 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "printer" { + content = <<-EOT +package printer // import "github.com/terramate-io/terramate/printer" + +Package printer defines funtionality for "printing" text to an io.Writer e.g. +os.Stdout, os.Stderr etc. with a consistent style for errors, warnings, +information etc. + +var Stderr = NewPrinter(os.Stderr) ... +type Printer struct{ ... } + func NewPrinter(w io.Writer) *Printer +EOT + + filename = "${path.module}/mock-printer.ignore" +} diff --git a/printer/stack.tm.hcl b/printer/stack.tm.hcl new file mode 100644 index 000000000..2a23549e4 --- /dev/null +++ b/printer/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package printer // import \"github.com/terramate-io/terramate/printer\"" + description = "package printer // import \"github.com/terramate-io/terramate/printer\"\n\nPackage printer defines funtionality for \"printing\" text to an io.Writer e.g.\nos.Stdout, os.Stderr etc. with a consistent style for errors, warnings,\ninformation etc.\n\nvar Stderr = NewPrinter(os.Stderr) ...\ntype Printer struct{ ... }\n func NewPrinter(w io.Writer) *Printer" + tags = ["golang", "printer"] + id = "79a0ef5a-2487-4a14-914b-43be60d8d661" +} diff --git a/project/_test_mock.tf b/project/_test_mock.tf new file mode 100644 index 000000000..2130f7f81 --- /dev/null +++ b/project/_test_mock.tf @@ -0,0 +1,20 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "project" { + content = <<-EOT +package project // import "github.com/terramate-io/terramate/project" + +Package project defines concepts that are related to a Terramate project. + +const MaxGlobalLabels = 256 +func AbsPath(root, prjAbsPath string) string +func FriendlyFmtDir(root, wd, dir string) (string, bool) +type Path struct{ ... } + func NewPath(p string) Path + func PrjAbsPath(root, abspath string) Path +type Paths []Path +type Runtime map[string]cty.Value +EOT + + filename = "${path.module}/mock-project.ignore" +} diff --git a/project/stack.tm.hcl b/project/stack.tm.hcl new file mode 100644 index 000000000..dd0819283 --- /dev/null +++ b/project/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package project // import \"github.com/terramate-io/terramate/project\"" + description = "package project // import \"github.com/terramate-io/terramate/project\"\n\nPackage project defines concepts that are related to a Terramate project.\n\nconst MaxGlobalLabels = 256\nfunc AbsPath(root, prjAbsPath string) string\nfunc FriendlyFmtDir(root, wd, dir string) (string, bool)\ntype Path struct{ ... }\n func NewPath(p string) Path\n func PrjAbsPath(root, abspath string) Path\ntype Paths []Path\ntype Runtime map[string]cty.Value" + tags = ["golang", "project"] + id = "7c65ebb6-5d66-49f8-a38c-0c39d51075f2" +} diff --git a/run/_test_mock.tf b/run/_test_mock.tf new file mode 100644 index 000000000..5cf6caa70 --- /dev/null +++ b/run/_test_mock.tf @@ -0,0 +1,21 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "run" { + content = <<-EOT +package run // import "github.com/terramate-io/terramate/run" + +Package run provides facilities to run commands inside Terramate context and +ordering. + +const ErrLoadingGlobals errors.Kind = "loading globals to evaluate terramate.config.run.env configuration" ... +const ErrNotFound errors.Kind = "executable file not found in $PATH" +func BuildDAG(d *dag.DAG[*config.Stack], root *config.Root, s *config.Stack, ...) error +func BuildDAGFromStacks[S ~[]E, E any](root *config.Root, items S, getStack func(E) *config.Stack) (*dag.DAG[E], string, error) +func LookPath(file string, environ []string) (string, error) +func Sort[S ~[]E, E any](root *config.Root, items S, getStack func(E) *config.Stack) (string, error) +type EnvVars []string + func LoadEnv(root *config.Root, st *config.Stack) (EnvVars, error) +EOT + + filename = "${path.module}/mock-run.ignore" +} diff --git a/run/dag/_test_mock.tf b/run/dag/_test_mock.tf new file mode 100644 index 000000000..b7b18b97d --- /dev/null +++ b/run/dag/_test_mock.tf @@ -0,0 +1,21 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "dag" { + content = <<-EOT +package dag // import "github.com/terramate-io/terramate/run/dag" + +Package dag provides the Directed-Acyclic-Graph (DAG) primitives required +by Terramate. The nodes can be added by providing both the descendants and +ancestors of each node but only the descendant -> ancestors relationship is +kept. + +const ErrDuplicateNode errors.Kind = "duplicate node" ... +type DAG[V any] struct{ ... } + func New[V any]() *DAG[V] + func Transform[D, S any](from *DAG[S], f func(id ID, v S) (D, error)) (*DAG[D], error) +type ID string +type Visited map[ID]struct{} +EOT + + filename = "${path.module}/mock-dag.ignore" +} diff --git a/run/dag/stack.tm.hcl b/run/dag/stack.tm.hcl new file mode 100644 index 000000000..c42f8a2f1 --- /dev/null +++ b/run/dag/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package dag // import \"github.com/terramate-io/terramate/run/dag\"" + description = "package dag // import \"github.com/terramate-io/terramate/run/dag\"\n\nPackage dag provides the Directed-Acyclic-Graph (DAG) primitives required\nby Terramate. The nodes can be added by providing both the descendants and\nancestors of each node but only the descendant -> ancestors relationship is\nkept.\n\nconst ErrDuplicateNode errors.Kind = \"duplicate node\" ...\ntype DAG[V any] struct{ ... }\n func New[V any]() *DAG[V]\n func Transform[D, S any](from *DAG[S], f func(id ID, v S) (D, error)) (*DAG[D], error)\ntype ID string\ntype Visited map[ID]struct{}" + tags = ["dag", "golang", "run"] + id = "4afcc942-9533-4d27-86d5-fa24d0b099be" +} diff --git a/run/stack.tm.hcl b/run/stack.tm.hcl new file mode 100644 index 000000000..d2a6f2184 --- /dev/null +++ b/run/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package run // import \"github.com/terramate-io/terramate/run\"" + description = "package run // import \"github.com/terramate-io/terramate/run\"\n\nPackage run provides facilities to run commands inside Terramate context and\nordering.\n\nconst ErrLoadingGlobals errors.Kind = \"loading globals to evaluate terramate.config.run.env configuration\" ...\nconst ErrNotFound errors.Kind = \"executable file not found in $PATH\"\nfunc BuildDAG(d *dag.DAG[*config.Stack], root *config.Root, s *config.Stack, ...) error\nfunc BuildDAGFromStacks[S ~[]E, E any](root *config.Root, items S, getStack func(E) *config.Stack) (*dag.DAG[E], string, error)\nfunc LookPath(file string, environ []string) (string, error)\nfunc Sort[S ~[]E, E any](root *config.Root, items S, getStack func(E) *config.Stack) (string, error)\ntype EnvVars []string\n func LoadEnv(root *config.Root, st *config.Stack) (EnvVars, error)" + tags = ["golang", "run"] + id = "aa1d4216-7901-4f5b-aeab-1d1ece0baa2b" +} diff --git a/safeguard/_test_mock.tf b/safeguard/_test_mock.tf new file mode 100644 index 000000000..5374b01c9 --- /dev/null +++ b/safeguard/_test_mock.tf @@ -0,0 +1,17 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "safeguard" { + content = <<-EOT +package safeguard // import "github.com/terramate-io/terramate/safeguard" + +Package safeguard provides types and methods for dealing with safeguards +keywords. + +type Keyword string + const All Keyword = "all" ... +type Keywords []Keyword + func FromStrings(strs []string) (Keywords, error) +EOT + + filename = "${path.module}/mock-safeguard.ignore" +} diff --git a/safeguard/stack.tm.hcl b/safeguard/stack.tm.hcl new file mode 100644 index 000000000..ea7079472 --- /dev/null +++ b/safeguard/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package safeguard // import \"github.com/terramate-io/terramate/safeguard\"" + description = "package safeguard // import \"github.com/terramate-io/terramate/safeguard\"\n\nPackage safeguard provides types and methods for dealing with safeguards\nkeywords.\n\ntype Keyword string\n const All Keyword = \"all\" ...\ntype Keywords []Keyword\n func FromStrings(strs []string) (Keywords, error)" + tags = ["golang", "safeguard"] + id = "5b526d39-4c1a-4d18-9f61-5302e8d88fdc" +} diff --git a/scheduler/_test_mock.tf b/scheduler/_test_mock.tf new file mode 100644 index 000000000..ed336ebde --- /dev/null +++ b/scheduler/_test_mock.tf @@ -0,0 +1,19 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "scheduler" { + content = <<-EOT +package scheduler // import "github.com/terramate-io/terramate/scheduler" + +Package scheduler defines schedulers to execute functions on DAGs based on a +specific scheduling strategy. + +type Func[V any] func(V) error +type Parallel[V any] struct{ ... } + func NewParallel[V any](d *dag.DAG[V], reverse bool) *Parallel[V] +type S[V any] interface{ ... } +type Sequential[V any] struct{ ... } + func NewSequential[V any](d *dag.DAG[V], reverse bool) *Sequential[V] +EOT + + filename = "${path.module}/mock-scheduler.ignore" +} diff --git a/scheduler/resource/_test_mock.tf b/scheduler/resource/_test_mock.tf new file mode 100644 index 000000000..6898cfe86 --- /dev/null +++ b/scheduler/resource/_test_mock.tf @@ -0,0 +1,17 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "resource" { + content = <<-EOT +package resource // import "github.com/terramate-io/terramate/scheduler/resource" + +Package resource defines different concurrent access strategies for resources. + +type Bounded struct{ ... } + func NewBounded(n int) *Bounded +type R interface{ ... } +type Throttled struct{ ... } + func NewThrottled(requestsPerSecond int64) *Throttled +EOT + + filename = "${path.module}/mock-resource.ignore" +} diff --git a/scheduler/resource/stack.tm.hcl b/scheduler/resource/stack.tm.hcl new file mode 100644 index 000000000..e66a43c8f --- /dev/null +++ b/scheduler/resource/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package resource // import \"github.com/terramate-io/terramate/scheduler/resource\"" + description = "package resource // import \"github.com/terramate-io/terramate/scheduler/resource\"\n\nPackage resource defines different concurrent access strategies for resources.\n\ntype Bounded struct{ ... }\n func NewBounded(n int) *Bounded\ntype R interface{ ... }\ntype Throttled struct{ ... }\n func NewThrottled(requestsPerSecond int64) *Throttled" + tags = ["golang", "resource", "scheduler"] + id = "580bae4e-4ca4-422d-8529-4b06849ce989" +} diff --git a/scheduler/stack.tm.hcl b/scheduler/stack.tm.hcl new file mode 100644 index 000000000..4ade64fc9 --- /dev/null +++ b/scheduler/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package scheduler // import \"github.com/terramate-io/terramate/scheduler\"" + description = "package scheduler // import \"github.com/terramate-io/terramate/scheduler\"\n\nPackage scheduler defines schedulers to execute functions on DAGs based on a\nspecific scheduling strategy.\n\ntype Func[V any] func(V) error\ntype Parallel[V any] struct{ ... }\n func NewParallel[V any](d *dag.DAG[V], reverse bool) *Parallel[V]\ntype S[V any] interface{ ... }\ntype Sequential[V any] struct{ ... }\n func NewSequential[V any](d *dag.DAG[V], reverse bool) *Sequential[V]" + tags = ["golang", "scheduler"] + id = "5215a993-ae93-4799-a113-1adb9fdbc69e" +} diff --git a/scripts.tm b/scripts.tm new file mode 100644 index 000000000..a53ac1fb8 --- /dev/null +++ b/scripts.tm @@ -0,0 +1,62 @@ +// Copyright 2023 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +globals { + planfile = "out.tfplan" +} + +script "test" { + name = "Terramate tests" + + job { + commands = [ + ["bash", "-c", "terraform init -lock=false >/dev/null"], + ["bash", "-c", "terraform plan -out=${global.planfile} >/dev/null"] + ] + } + + job { + command = [ + "go", "test", "-race", "-count=1", "-timeout", "30m"] + } +} + +script "preview" { + name = "Preview Terramate tests" + + job { + commands = [ + ["bash", "-c", "terraform init -lock=false >/dev/null"], + ["bash", "-c", "terraform plan -out=${global.planfile} >/dev/null"] + ] + } + + job { + command = [ + "go", "test", "-race", "-count=1", "-timeout", "30m", { + sync_preview = true, + terraform_plan_file = global.planfile, + } + ] + } +} + +script "deploy" { + name = "Deploy Terramate tests" + + job { + commands = [ + ["bash", "-c", "terraform init -lock=false >/dev/null"], + ["bash", "-c", "terraform plan -out=${global.planfile} >/dev/null"] + ] + } + + job { + command = [ + "go", "test", "-race", "-count=1", "-timeout", "30m", { + sync_deployment = true, + terraform_plan_file = global.planfile, + } + ] + } +} diff --git a/stack.tm b/stack.tm deleted file mode 100644 index 176cdbabb..000000000 --- a/stack.tm +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2023 Terramate GmbH -// SPDX-License-Identifier: MPL-2.0 - -stack { - name = "terramate" - description = "terramate source code" - id = "4ff324cd-f338-4526-8bcb-28ec33bbaeea" - tags = [ - "golang", - ] -} diff --git a/stack.tm.hcl b/stack.tm.hcl new file mode 100644 index 000000000..df453f4d9 --- /dev/null +++ b/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package terramate // import \"github.com/terramate-io/terramate\"" + description = "package terramate // import \"github.com/terramate-io/terramate\"\n\nPackage terramate provides functions for managing terraform stacks. A stack is a\nunit of independent runnable terraform modules.\n\nfunc Version() string" + tags = ["golang"] + id = "ff77cc8c-87da-4411-bdbe-ad2feec7ba23" +} diff --git a/stack/_test_mock.tf b/stack/_test_mock.tf new file mode 100644 index 000000000..9d247dd83 --- /dev/null +++ b/stack/_test_mock.tf @@ -0,0 +1,29 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "stack" { + content = <<-EOT +package stack // import "github.com/terramate-io/terramate/stack" + +Package stack defines all functionality around stacks, like loading, listing all +stacks, etc. + +const ErrInvalidStackDir errors.Kind = "invalid stack directory" ... +const DefaultFilename = "stack.tm.hcl" +const ErrCloneDestDirExists errors.Kind = "clone dest dir exists" +func Clone(root *config.Root, destdir, srcdir string, skipChildStacks bool) (int, error) +func Create(root *config.Root, stack config.Stack, imports ...string) (err error) +func UpdateStackID(root *config.Root, stackdir string) (string, error) +type Entry struct{ ... } + func List(root *config.Root, cfg *config.Tree) ([]Entry, error) +type EntrySlice []Entry +type EvalCtx struct{ ... } + func NewEvalCtx(root *config.Root, stack *config.Stack, globals *eval.Object) *EvalCtx +type Manager struct{ ... } + func NewGitAwareManager(root *config.Root, git *git.Git) *Manager + func NewManager(root *config.Root) *Manager +type RepoChecks struct{ ... } +type Report struct{ ... } +EOT + + filename = "${path.module}/mock-stack.ignore" +} diff --git a/stack/stack.tm.hcl b/stack/stack.tm.hcl new file mode 100644 index 000000000..68047c945 --- /dev/null +++ b/stack/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package stack // import \"github.com/terramate-io/terramate/stack\"" + description = "package stack // import \"github.com/terramate-io/terramate/stack\"\n\nPackage stack defines all functionality around stacks, like loading, listing all\nstacks, etc.\n\nconst ErrInvalidStackDir errors.Kind = \"invalid stack directory\" ...\nconst DefaultFilename = \"stack.tm.hcl\"\nconst ErrCloneDestDirExists errors.Kind = \"clone dest dir exists\"\nfunc Clone(root *config.Root, destdir, srcdir string, skipChildStacks bool) (int, error)\nfunc Create(root *config.Root, stack config.Stack, imports ...string) (err error)\nfunc UpdateStackID(root *config.Root, stackdir string) (string, error)\ntype Entry struct{ ... }\n func List(root *config.Root, cfg *config.Tree) ([]Entry, error)\ntype EntrySlice []Entry\ntype EvalCtx struct{ ... }\n func NewEvalCtx(root *config.Root, stack *config.Stack, globals *eval.Object) *EvalCtx\ntype Manager struct{ ... }\n func NewGitAwareManager(root *config.Root, git *git.Git) *Manager\n func NewManager(root *config.Root) *Manager\ntype RepoChecks struct{ ... }\ntype Report struct{ ... }" + tags = ["golang", "stack"] + id = "a8048c52-cb21-454e-abdd-3245fe1e6ac3" +} diff --git a/stack/trigger/_test_mock.tf b/stack/trigger/_test_mock.tf new file mode 100644 index 000000000..6d7bcc1a3 --- /dev/null +++ b/stack/trigger/_test_mock.tf @@ -0,0 +1,22 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "trigger" { + content = <<-EOT +package trigger // import "github.com/terramate-io/terramate/stack/trigger" + +Package trigger provides functionality that help manipulate stacks triggers. + +const ErrTrigger errors.Kind = "trigger failed" ... +const DefaultContext = "stack" +func Create(root *config.Root, path project.Path, kind Kind, reason string) error +func Dir(rootdir string) string +func StackPath(triggerFile project.Path) (project.Path, bool) +type Info struct{ ... } + func Is(root *config.Root, filename project.Path) (info Info, stack project.Path, exists bool, err error) + func ParseFile(path string) (Info, error) +type Kind string + const Changed Kind = "changed" ... +EOT + + filename = "${path.module}/mock-trigger.ignore" +} diff --git a/stack/trigger/stack.tm.hcl b/stack/trigger/stack.tm.hcl new file mode 100644 index 000000000..4dfdac589 --- /dev/null +++ b/stack/trigger/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package trigger // import \"github.com/terramate-io/terramate/stack/trigger\"" + description = "package trigger // import \"github.com/terramate-io/terramate/stack/trigger\"\n\nPackage trigger provides functionality that help manipulate stacks triggers.\n\nconst ErrTrigger errors.Kind = \"trigger failed\" ...\nconst DefaultContext = \"stack\"\nfunc Create(root *config.Root, path project.Path, kind Kind, reason string) error\nfunc Dir(rootdir string) string\nfunc StackPath(triggerFile project.Path) (project.Path, bool)\ntype Info struct{ ... }\n func Is(root *config.Root, filename project.Path) (info Info, stack project.Path, exists bool, err error)\n func ParseFile(path string) (Info, error)\ntype Kind string\n const Changed Kind = \"changed\" ..." + tags = ["golang", "stack", "trigger"] + id = "c0f5d20b-0765-4c23-9c52-2905a1621caa" +} diff --git a/stdlib/_test_mock.tf b/stdlib/_test_mock.tf new file mode 100644 index 000000000..1c09235d5 --- /dev/null +++ b/stdlib/_test_mock.tf @@ -0,0 +1,28 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "stdlib" { + content = <<-EOT +package stdlib // import "github.com/terramate-io/terramate/stdlib" + +Package stdlib implements the Terramate language functions. + +const ErrTomlDecode errors.Kind = "failed to decode toml content" +const TomlExperimentName = "toml-functions" +func AbspathFunc(basedir string) function.Function +func Functions(basedir string, experiments []string) map[string]function.Function +func HCLDecode() function.Function +func HCLEncode() function.Function +func HCLExpressionFunc() function.Function +func Name(name string) string +func NoFS(basedir string, experiments []string) map[string]function.Function +func Regex() function.Function +func TernaryFunc() function.Function +func TomlDecode() function.Function +func TomlEncode() function.Function +func TryFunc() function.Function +func VendorFunc(basedir, vendordir project.Path, stream chan<- event.VendorRequest) function.Function +func VersionMatch() function.Function +EOT + + filename = "${path.module}/mock-stdlib.ignore" +} diff --git a/stdlib/stack.tm.hcl b/stdlib/stack.tm.hcl new file mode 100644 index 000000000..921faca7a --- /dev/null +++ b/stdlib/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package stdlib // import \"github.com/terramate-io/terramate/stdlib\"" + description = "package stdlib // import \"github.com/terramate-io/terramate/stdlib\"\n\nPackage stdlib implements the Terramate language functions.\n\nconst ErrTomlDecode errors.Kind = \"failed to decode toml content\"\nconst TomlExperimentName = \"toml-functions\"\nfunc AbspathFunc(basedir string) function.Function\nfunc Functions(basedir string, experiments []string) map[string]function.Function\nfunc HCLDecode() function.Function\nfunc HCLEncode() function.Function\nfunc HCLExpressionFunc() function.Function\nfunc Name(name string) string\nfunc NoFS(basedir string, experiments []string) map[string]function.Function\nfunc Regex() function.Function\nfunc TernaryFunc() function.Function\nfunc TomlDecode() function.Function\nfunc TomlEncode() function.Function\nfunc TryFunc() function.Function\nfunc VendorFunc(basedir, vendordir project.Path, stream chan<- event.VendorRequest) function.Function\nfunc VersionMatch() function.Function" + tags = ["golang", "stdlib"] + id = "707e82ed-bed0-42e4-8f99-a6a215b3d4cf" +} diff --git a/strconv/_test_mock.tf b/strconv/_test_mock.tf new file mode 100644 index 000000000..762b47baa --- /dev/null +++ b/strconv/_test_mock.tf @@ -0,0 +1,14 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "strconv" { + content = <<-EOT +package strconv // import "github.com/terramate-io/terramate/strconv" + +Package strconv provides helper functions for the Go standard strconv package. + +func Atoi64(a string) (int64, error) +func Itoa64(i int64) string +EOT + + filename = "${path.module}/mock-strconv.ignore" +} diff --git a/strconv/stack.tm.hcl b/strconv/stack.tm.hcl new file mode 100644 index 000000000..6f20d9ae2 --- /dev/null +++ b/strconv/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package strconv // import \"github.com/terramate-io/terramate/strconv\"" + description = "package strconv // import \"github.com/terramate-io/terramate/strconv\"\n\nPackage strconv provides helper functions for the Go standard strconv package.\n\nfunc Atoi64(a string) (int64, error)\nfunc Itoa64(i int64) string" + tags = ["golang", "strconv"] + id = "1497d99c-2088-4ca4-87e1-4c1a182b78ec" +} diff --git a/terramate.tm b/terramate.tm index 822623c75..f7f060f04 100644 --- a/terramate.tm +++ b/terramate.tm @@ -1,15 +1,9 @@ // Copyright 2023 Terramate GmbH // SPDX-License-Identifier: MPL-2.0 -# This file is here just to e2etest on Windows if the `terramate run` respects -# the `terramate.config.run.env.PATH` environment variable. -# This behavior is not tested in Go because it requires a lot of "unsafe" -# non-portable code. -# It's used by the `make test` implemented for Windows at ./makefiles/windows.mk - terramate { config { - experiments = ["toml-functions"] + experiments = ["toml-functions", "scripts", "targets"] run { env { PATH = "${terramate.root.path.fs.absolute}/bin${global.PS}${env.PATH}" @@ -21,6 +15,14 @@ terramate { check_uncommitted = false check_remote = false } + + cloud { + organization = "terramate-tests" + + targets { + enabled = true + } + } } } @@ -28,3 +30,4 @@ globals { # TODO(i4k): very brittle but works for now. PS = tm_fileexists("/etc/hosts") ? ":" : ";" } + diff --git a/test/_test_mock.tf b/test/_test_mock.tf new file mode 100644 index 000000000..803b8ffc2 --- /dev/null +++ b/test/_test_mock.tf @@ -0,0 +1,56 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "test" { + content = <<-EOT +package test // import "github.com/terramate-io/terramate/test" + +Package test provides testing routines reused throughout terramate code base. + +const Username = "terramate tests" ... +func AppendFile(t testing.TB, dir string, filename string, content string) +func AssertChmod(t testing.TB, fname string, mode fs.FileMode) +func AssertConfigEquals(t *testing.T, got, want []config.Assert) +func AssertDiff(t *testing.T, got, want interface{}, msg ...interface{}) +func AssertEqualPaths(t *testing.T, got, want project.Path, fmtargs ...any) +func AssertEqualPos(t *testing.T, got, want info.Pos, fmtargs ...any) +func AssertEqualRanges(t *testing.T, got, want info.Range, fmtargs ...any) +func AssertEqualSets[T comparable](t *testing.T, got, want []T) +func AssertFileContentEquals(t *testing.T, fname string, want string) +func AssertFileEquals(t *testing.T, filepath1, filepath2 string) +func AssertGenCodeEquals(t *testing.T, got string, want string) +func AssertStackImports(t *testing.T, rootdir string, stackHostPath string, want []string) +func AssertStacks(t testing.TB, got, want config.Stack) +func AssertTerramateConfig(t *testing.T, got, want hcl.Config) +func AssertTreeEquals(t *testing.T, dir1, dir2 string) +func CanonPath(t testing.TB, path string) string +func Chmod(fname string, mode fs.FileMode) error +func DoesNotExist(t testing.TB, dir, fname string) +func EmptyRepo(t testing.TB, bare bool) string +func FixupRangeOnAsserts(dir string, asserts []config.Assert) +func Getwd(t testing.TB) string +func IsDir(t testing.TB, dir, fname string) +func IsFile(t testing.TB, dir, fname string) +func LookPath(t *testing.T, file string) string +func Mkdir(t testing.TB, base string, name string) string +func MkdirAll(t testing.TB, path string) +func MkdirAll2(t testing.TB, path string, perm fs.FileMode) +func NewExpr(t *testing.T, expr string) hhcl.Expression +func NewGitWrapper(t testing.TB, wd string, env []string) *git.Git +func NewRepo(t testing.TB) string +func NonExistingDir(t testing.TB) string +func ParseSource(t *testing.T, source string) tf.Source +func ParseTerramateConfig(t *testing.T, dir string) hcl.Config +func PrependToPath(env []string, dir string) ([]string, bool) +func ReadDir(t testing.TB, dir string) []os.DirEntry +func ReadFile(t testing.TB, dir, fname string) []byte +func RelPath(t testing.TB, basepath, targetpath string) string +func RemoveAll(t testing.TB, path string) +func RemoveFile(t testing.TB, dir, fname string) +func Symlink(t testing.TB, oldname, newname string) +func TempDir(t testing.TB) string +func WriteFile(t testing.TB, dir string, filename string, content string) string +func WriteRootConfig(t testing.TB, rootdir string) +EOT + + filename = "${path.module}/mock-test.ignore" +} diff --git a/test/cloud/_test_mock.tf b/test/cloud/_test_mock.tf new file mode 100644 index 000000000..199ed4f8b --- /dev/null +++ b/test/cloud/_test_mock.tf @@ -0,0 +1,13 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "cloud" { + content = <<-EOT +package cloud // import "github.com/terramate-io/terramate/test/cloud" + +Package cloud provides testing helpers for the TMC cloud. + +func PutStack(t *testing.T, addr string, orgUUID cloud.UUID, st cloud.StackObject) +EOT + + filename = "${path.module}/mock-cloud.ignore" +} diff --git a/test/cloud/stack.tm.hcl b/test/cloud/stack.tm.hcl new file mode 100644 index 000000000..9a5c9531b --- /dev/null +++ b/test/cloud/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package cloud // import \"github.com/terramate-io/terramate/test/cloud\"" + description = "package cloud // import \"github.com/terramate-io/terramate/test/cloud\"\n\nPackage cloud provides testing helpers for the TMC cloud.\n\nfunc PutStack(t *testing.T, addr string, orgUUID cloud.UUID, st cloud.StackObject)" + tags = ["cloud", "golang", "test"] + id = "7ea9aa1d-86ce-4209-85a5-cec41f413a39" +} diff --git a/test/errors/_test_mock.tf b/test/errors/_test_mock.tf new file mode 100644 index 000000000..fcd51edf1 --- /dev/null +++ b/test/errors/_test_mock.tf @@ -0,0 +1,18 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "errors" { + content = <<-EOT +package errors // import "github.com/terramate-io/terramate/test/errors" + +Package errors provides useful assert functions for handling errors on tests + +func Assert(t *testing.T, err, target error, args ...interface{}) +func AssertAsErrorsList(t *testing.T, err error) +func AssertErrorList(t *testing.T, err error, targets []error) +func AssertIsErrors(t *testing.T, err error, targets []error) +func AssertIsKind(t *testing.T, err error, k errors.Kind) +func AssertKind(t *testing.T, got, want error) +EOT + + filename = "${path.module}/mock-errors.ignore" +} diff --git a/test/errors/stack.tm.hcl b/test/errors/stack.tm.hcl new file mode 100644 index 000000000..4af4649db --- /dev/null +++ b/test/errors/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package errors // import \"github.com/terramate-io/terramate/test/errors\"" + description = "package errors // import \"github.com/terramate-io/terramate/test/errors\"\n\nPackage errors provides useful assert functions for handling errors on tests\n\nfunc Assert(t *testing.T, err, target error, args ...interface{})\nfunc AssertAsErrorsList(t *testing.T, err error)\nfunc AssertErrorList(t *testing.T, err error, targets []error)\nfunc AssertIsErrors(t *testing.T, err error, targets []error)\nfunc AssertIsKind(t *testing.T, err error, k errors.Kind)\nfunc AssertKind(t *testing.T, got, want error)" + tags = ["errors", "golang", "test"] + id = "1799cd5a-2c75-4fea-a381-18f31a7b0375" +} diff --git a/test/hclutils/_test_mock.tf b/test/hclutils/_test_mock.tf new file mode 100644 index 000000000..1305192ab --- /dev/null +++ b/test/hclutils/_test_mock.tf @@ -0,0 +1,16 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "hclutils" { + content = <<-EOT +package hclutils // import "github.com/terramate-io/terramate/test/hclutils" + +Package hclutils provides test utils related to hcl. + +func End(line, column, char int) hhcl.Pos +func FixupFiledirOnErrorsFileRanges(dir string, errs []error) +func Mkrange(fname string, start, end hhcl.Pos) hhcl.Range +func Start(line, column, char int) hhcl.Pos +EOT + + filename = "${path.module}/mock-hclutils.ignore" +} diff --git a/test/hclutils/info/_test_mock.tf b/test/hclutils/info/_test_mock.tf new file mode 100644 index 000000000..31d440aeb --- /dev/null +++ b/test/hclutils/info/_test_mock.tf @@ -0,0 +1,15 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "info" { + content = <<-EOT +package info // import "github.com/terramate-io/terramate/test/hclutils/info" + +Package info provides functions useful to create types like info.Range + +func FixRange(rootdir string, old info.Range) info.Range +func FixRangesOnConfig(dir string, cfg hcl.Config) +func Range(fname string, start, end hhcl.Pos) info.Range +EOT + + filename = "${path.module}/mock-info.ignore" +} diff --git a/test/hclutils/info/stack.tm.hcl b/test/hclutils/info/stack.tm.hcl new file mode 100644 index 000000000..17675a948 --- /dev/null +++ b/test/hclutils/info/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package info // import \"github.com/terramate-io/terramate/test/hclutils/info\"" + description = "package info // import \"github.com/terramate-io/terramate/test/hclutils/info\"\n\nPackage info provides functions useful to create types like info.Range\n\nfunc FixRange(rootdir string, old info.Range) info.Range\nfunc FixRangesOnConfig(dir string, cfg hcl.Config)\nfunc Range(fname string, start, end hhcl.Pos) info.Range" + tags = ["golang", "hclutils", "info", "test"] + id = "d997cacf-1b94-4315-a860-2ad654150d04" +} diff --git a/test/hclutils/stack.tm.hcl b/test/hclutils/stack.tm.hcl new file mode 100644 index 000000000..7caf5e25e --- /dev/null +++ b/test/hclutils/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package hclutils // import \"github.com/terramate-io/terramate/test/hclutils\"" + description = "package hclutils // import \"github.com/terramate-io/terramate/test/hclutils\"\n\nPackage hclutils provides test utils related to hcl.\n\nfunc End(line, column, char int) hhcl.Pos\nfunc FixupFiledirOnErrorsFileRanges(dir string, errs []error)\nfunc Mkrange(fname string, start, end hhcl.Pos) hhcl.Range\nfunc Start(line, column, char int) hhcl.Pos" + tags = ["golang", "hclutils", "test"] + id = "a1229483-5d7c-4745-bfe9-55b2b0825852" +} diff --git a/test/hclwrite/_test_mock.tf b/test/hclwrite/_test_mock.tf new file mode 100644 index 000000000..165dccad7 --- /dev/null +++ b/test/hclwrite/_test_mock.tf @@ -0,0 +1,38 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "hclwrite" { + content = <<-EOT +package hclwrite // import "github.com/terramate-io/terramate/test/hclwrite" + +Package hclwrite aims to provide some facilities making it easier/safer to +generate HCL code for testing purposes. It aims at: + +- Close to how HCL is written. - Provide formatted string representation. +- Avoid issues when raw HCL strings are used on tests in general. + +It is not a replacement to hclwrite: +https://pkg.go.dev/github.com/hashicorp/hcl/v2/hclwrite It is just easier/nicer +to use on tests + circumvents some limitations like: + +- +https://stackoverflow.com/questions/67945463/how-to-use-hcl-write-to-set-expressions-with + +We are missing a way to build objects and lists with a similar syntax to blocks. +For now we circumvent this with the AttributeValue function. + +func Format(code string) string +type Block struct{ ... } + func BuildBlock(name string, builders ...BlockBuilder) *Block + func BuildHCL(builders ...BlockBuilder) *Block +type BlockBuilder interface{ ... } + func AttributeValue(t *testing.T, name string, expr string) BlockBuilder + func Boolean(name string, val bool) BlockBuilder + func Expression(name string, expr string) BlockBuilder + func Labels(labels ...string) BlockBuilder + func NumberInt(name string, val int64) BlockBuilder + func String(name string, val string) BlockBuilder +type BlockBuilderFunc func(*Block) +EOT + + filename = "${path.module}/mock-hclwrite.ignore" +} diff --git a/test/hclwrite/hclutils/_test_mock.tf b/test/hclwrite/hclutils/_test_mock.tf new file mode 100644 index 000000000..a3b1007e8 --- /dev/null +++ b/test/hclwrite/hclutils/_test_mock.tf @@ -0,0 +1,55 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "hclutils" { + content = <<-EOT +package hclutils // import "github.com/terramate-io/terramate/test/hclwrite/hclutils" + +Package hclutils provides useful functions to build HCL documents. It is usually +imported with . so building HCL documents can be done very fluently and yet in a +type safe manner. + +func Assert(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Backend(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Block(name string, builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Bool(name string, val bool) hclwrite.BlockBuilder +func Command(args ...string) hclwrite.BlockBuilder +func Commands(args ...[]string) hclwrite.BlockBuilder +func Config(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Content(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Default(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Doc(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Env(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func EvalExpr(t *testing.T, name string, expr string) hclwrite.BlockBuilder +func Experiments(names ...string) hclwrite.BlockBuilder +func Expr(name string, expr string) hclwrite.BlockBuilder +func GenerateFile(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func GenerateHCL(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Globals(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Import(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Input(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Labels(labels ...string) hclwrite.BlockBuilder +func Lets(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Locals(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Manifest(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Map(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Module(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Number(name string, val int64) hclwrite.BlockBuilder +func Output(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func ProjectPaths(paths ...string) hclwrite.BlockBuilder +func RepositoryPaths(paths ...string) hclwrite.BlockBuilder +func Run(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Script(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Stack(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func StackFilter(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Str(name string, val string) hclwrite.BlockBuilder +func Terraform(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Terramate(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func TmDynamic(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Trigger(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Value(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Variable(builders ...hclwrite.BlockBuilder) *hclwrite.Block +func Vendor(builders ...hclwrite.BlockBuilder) *hclwrite.Block +EOT + + filename = "${path.module}/mock-hclutils.ignore" +} diff --git a/test/hclwrite/hclutils/stack.tm.hcl b/test/hclwrite/hclutils/stack.tm.hcl new file mode 100644 index 000000000..eea5f37fb --- /dev/null +++ b/test/hclwrite/hclutils/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package hclutils // import \"github.com/terramate-io/terramate/test/hclwrite/hclutils\"" + description = "package hclutils // import \"github.com/terramate-io/terramate/test/hclwrite/hclutils\"\n\nPackage hclutils provides useful functions to build HCL documents. It is usually\nimported with . so building HCL documents can be done very fluently and yet in a\ntype safe manner.\n\nfunc Assert(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Backend(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Block(name string, builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Bool(name string, val bool) hclwrite.BlockBuilder\nfunc Command(args ...string) hclwrite.BlockBuilder\nfunc Commands(args ...[]string) hclwrite.BlockBuilder\nfunc Config(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Content(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Default(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Doc(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Env(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc EvalExpr(t *testing.T, name string, expr string) hclwrite.BlockBuilder\nfunc Experiments(names ...string) hclwrite.BlockBuilder\nfunc Expr(name string, expr string) hclwrite.BlockBuilder\nfunc GenerateFile(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc GenerateHCL(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Globals(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Import(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Input(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Labels(labels ...string) hclwrite.BlockBuilder\nfunc Lets(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Locals(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Manifest(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Map(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Module(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Number(name string, val int64) hclwrite.BlockBuilder\nfunc Output(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc ProjectPaths(paths ...string) hclwrite.BlockBuilder\nfunc RepositoryPaths(paths ...string) hclwrite.BlockBuilder\nfunc Run(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Script(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Stack(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc StackFilter(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Str(name string, val string) hclwrite.BlockBuilder\nfunc Terraform(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Terramate(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc TmDynamic(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Trigger(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Value(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Variable(builders ...hclwrite.BlockBuilder) *hclwrite.Block\nfunc Vendor(builders ...hclwrite.BlockBuilder) *hclwrite.Block" + tags = ["golang", "hclutils", "hclwrite", "test"] + id = "acce0447-b15a-42d9-9252-dfe465fc5110" +} diff --git a/test/hclwrite/stack.tm.hcl b/test/hclwrite/stack.tm.hcl new file mode 100644 index 000000000..9a47da2f7 --- /dev/null +++ b/test/hclwrite/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package hclwrite // import \"github.com/terramate-io/terramate/test/hclwrite\"" + description = "package hclwrite // import \"github.com/terramate-io/terramate/test/hclwrite\"\n\nPackage hclwrite aims to provide some facilities making it easier/safer to\ngenerate HCL code for testing purposes. It aims at:\n\n- Close to how HCL is written. - Provide formatted string representation.\n- Avoid issues when raw HCL strings are used on tests in general.\n\nIt is not a replacement to hclwrite:\nhttps://pkg.go.dev/github.com/hashicorp/hcl/v2/hclwrite It is just easier/nicer\nto use on tests + circumvents some limitations like:\n\n-\nhttps://stackoverflow.com/questions/67945463/how-to-use-hcl-write-to-set-expressions-with\n\nWe are missing a way to build objects and lists with a similar syntax to blocks.\nFor now we circumvent this with the AttributeValue function.\n\nfunc Format(code string) string\ntype Block struct{ ... }\n func BuildBlock(name string, builders ...BlockBuilder) *Block\n func BuildHCL(builders ...BlockBuilder) *Block\ntype BlockBuilder interface{ ... }\n func AttributeValue(t *testing.T, name string, expr string) BlockBuilder\n func Boolean(name string, val bool) BlockBuilder\n func Expression(name string, expr string) BlockBuilder\n func Labels(labels ...string) BlockBuilder\n func NumberInt(name string, val int64) BlockBuilder\n func String(name string, val string) BlockBuilder\ntype BlockBuilderFunc func(*Block)" + tags = ["golang", "hclwrite", "test"] + id = "967e7bd6-f743-4a10-bda9-5ca55e8efde5" +} diff --git a/test/ls/_test_mock.tf b/test/ls/_test_mock.tf new file mode 100644 index 000000000..0198f181d --- /dev/null +++ b/test/ls/_test_mock.tf @@ -0,0 +1,19 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "ls" { + content = <<-EOT +package ls // import "github.com/terramate-io/terramate/test/ls" + +Package ls provides test utilities used when testing the Terramate Language +Server. + +func DefaultInitializeResult() lsp.InitializeResult +type Editor struct{ ... } + func NewEditor(t *testing.T, s sandbox.S, conn jsonrpc2.Conn) *Editor +type Fixture struct{ ... } + func Setup(t *testing.T, layout ...string) Fixture + func SetupNoRootConfig(t *testing.T, layout ...string) Fixture +EOT + + filename = "${path.module}/mock-ls.ignore" +} diff --git a/test/ls/stack.tm.hcl b/test/ls/stack.tm.hcl new file mode 100644 index 000000000..310693327 --- /dev/null +++ b/test/ls/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package ls // import \"github.com/terramate-io/terramate/test/ls\"" + description = "package ls // import \"github.com/terramate-io/terramate/test/ls\"\n\nPackage ls provides test utilities used when testing the Terramate Language\nServer.\n\nfunc DefaultInitializeResult() lsp.InitializeResult\ntype Editor struct{ ... }\n func NewEditor(t *testing.T, s sandbox.S, conn jsonrpc2.Conn) *Editor\ntype Fixture struct{ ... }\n func Setup(t *testing.T, layout ...string) Fixture\n func SetupNoRootConfig(t *testing.T, layout ...string) Fixture" + tags = ["golang", "ls", "test"] + id = "288082d0-0e81-4e03-9792-cfaa2055cef6" +} diff --git a/test/sandbox/_test_mock.tf b/test/sandbox/_test_mock.tf new file mode 100644 index 000000000..bd016cfa9 --- /dev/null +++ b/test/sandbox/_test_mock.tf @@ -0,0 +1,31 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "sandbox" { + content = <<-EOT +package sandbox // import "github.com/terramate-io/terramate/test/sandbox" + +Package sandbox provides an easy way to setup isolated terramate projects that +can be used on testing, acting like sandboxes. + +It helps with: + +- git initialization/operations - Terraform module creation - Terramate stack +creation + +type AssertTreeOption func(o *assertTreeOptions) + func WithStrictStackValidation() AssertTreeOption +type DirEntry struct{ ... } +type FileEntry struct{ ... } +type Git struct{ ... } + func NewGit(t testing.TB, repodir string) *Git + func NewGitWithConfig(t testing.TB, cfg GitConfig) *Git +type GitConfig struct{ ... } +type S struct{ ... } + func New(t testing.TB) S + func NewWithGitConfig(t testing.TB, cfg GitConfig) S + func NoGit(t testing.TB, createProject bool) S +type StackEntry struct{ ... } +EOT + + filename = "${path.module}/mock-sandbox.ignore" +} diff --git a/test/sandbox/stack.tm.hcl b/test/sandbox/stack.tm.hcl new file mode 100644 index 000000000..3d04311b6 --- /dev/null +++ b/test/sandbox/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package sandbox // import \"github.com/terramate-io/terramate/test/sandbox\"" + description = "package sandbox // import \"github.com/terramate-io/terramate/test/sandbox\"\n\nPackage sandbox provides an easy way to setup isolated terramate projects that\ncan be used on testing, acting like sandboxes.\n\nIt helps with:\n\n- git initialization/operations - Terraform module creation - Terramate stack\ncreation\n\ntype AssertTreeOption func(o *assertTreeOptions)\n func WithStrictStackValidation() AssertTreeOption\ntype DirEntry struct{ ... }\ntype FileEntry struct{ ... }\ntype Git struct{ ... }\n func NewGit(t testing.TB, repodir string) *Git\n func NewGitWithConfig(t testing.TB, cfg GitConfig) *Git\ntype GitConfig struct{ ... }\ntype S struct{ ... }\n func New(t testing.TB) S\n func NewWithGitConfig(t testing.TB, cfg GitConfig) S\n func NoGit(t testing.TB, createProject bool) S\ntype StackEntry struct{ ... }" + tags = ["golang", "sandbox", "test"] + id = "b88ff761-d470-4bab-b830-c7dcc54e93f4" +} diff --git a/test/stack.tm.hcl b/test/stack.tm.hcl new file mode 100644 index 000000000..60ee5f585 --- /dev/null +++ b/test/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package test // import \"github.com/terramate-io/terramate/test\"" + description = "package test // import \"github.com/terramate-io/terramate/test\"\n\nPackage test provides testing routines reused throughout terramate code base.\n\nconst Username = \"terramate tests\" ...\nfunc AppendFile(t testing.TB, dir string, filename string, content string)\nfunc AssertChmod(t testing.TB, fname string, mode fs.FileMode)\nfunc AssertConfigEquals(t *testing.T, got, want []config.Assert)\nfunc AssertDiff(t *testing.T, got, want interface{}, msg ...interface{})\nfunc AssertEqualPaths(t *testing.T, got, want project.Path, fmtargs ...any)\nfunc AssertEqualPos(t *testing.T, got, want info.Pos, fmtargs ...any)\nfunc AssertEqualRanges(t *testing.T, got, want info.Range, fmtargs ...any)\nfunc AssertEqualSets[T comparable](t *testing.T, got, want []T)\nfunc AssertFileContentEquals(t *testing.T, fname string, want string)\nfunc AssertFileEquals(t *testing.T, filepath1, filepath2 string)\nfunc AssertGenCodeEquals(t *testing.T, got string, want string)\nfunc AssertStackImports(t *testing.T, rootdir string, stackHostPath string, want []string)\nfunc AssertStacks(t testing.TB, got, want config.Stack)\nfunc AssertTerramateConfig(t *testing.T, got, want hcl.Config)\nfunc AssertTreeEquals(t *testing.T, dir1, dir2 string)\nfunc CanonPath(t testing.TB, path string) string\nfunc Chmod(fname string, mode fs.FileMode) error\nfunc DoesNotExist(t testing.TB, dir, fname string)\nfunc EmptyRepo(t testing.TB, bare bool) string\nfunc FixupRangeOnAsserts(dir string, asserts []config.Assert)\nfunc Getwd(t testing.TB) string\nfunc IsDir(t testing.TB, dir, fname string)\nfunc IsFile(t testing.TB, dir, fname string)\nfunc LookPath(t *testing.T, file string) string\nfunc Mkdir(t testing.TB, base string, name string) string\nfunc MkdirAll(t testing.TB, path string)\nfunc MkdirAll2(t testing.TB, path string, perm fs.FileMode)\nfunc NewExpr(t *testing.T, expr string) hhcl.Expression\nfunc NewGitWrapper(t testing.TB, wd string, env []string) *git.Git\nfunc NewRepo(t testing.TB) string\nfunc NonExistingDir(t testing.TB) string\nfunc ParseSource(t *testing.T, source string) tf.Source\nfunc ParseTerramateConfig(t *testing.T, dir string) hcl.Config\nfunc PrependToPath(env []string, dir string) ([]string, bool)\nfunc ReadDir(t testing.TB, dir string) []os.DirEntry\nfunc ReadFile(t testing.TB, dir, fname string) []byte\nfunc RelPath(t testing.TB, basepath, targetpath string) string\nfunc RemoveAll(t testing.TB, path string)\nfunc RemoveFile(t testing.TB, dir, fname string)\nfunc Symlink(t testing.TB, oldname, newname string)\nfunc TempDir(t testing.TB) string\nfunc WriteFile(t testing.TB, dir string, filename string, content string) string\nfunc WriteRootConfig(t testing.TB, rootdir string)" + tags = ["golang", "test"] + id = "d95b690e-7bff-4196-aec8-2a1a39d3a8dd" +} diff --git a/tf/_test_mock.tf b/tf/_test_mock.tf new file mode 100644 index 000000000..8108c6797 --- /dev/null +++ b/tf/_test_mock.tf @@ -0,0 +1,19 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "tf" { + content = <<-EOT +package tf // import "github.com/terramate-io/terramate/tf" + +Package tf provides parsing and abstractions specific to Terraform. + +const ErrUnsupportedModSrc errors.Kind = "unsupported module source" ... +const ErrHCLSyntax errors.Kind = "HCL syntax error" +func IsStack(path string) (bool, error) +type Module struct{ ... } + func ParseModules(path string) ([]Module, error) +type Source struct{ ... } + func ParseSource(modsource string) (Source, error) +EOT + + filename = "${path.module}/mock-tf.ignore" +} diff --git a/tf/stack.tm.hcl b/tf/stack.tm.hcl new file mode 100644 index 000000000..d99be5524 --- /dev/null +++ b/tf/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package tf // import \"github.com/terramate-io/terramate/tf\"" + description = "package tf // import \"github.com/terramate-io/terramate/tf\"\n\nPackage tf provides parsing and abstractions specific to Terraform.\n\nconst ErrUnsupportedModSrc errors.Kind = \"unsupported module source\" ...\nconst ErrHCLSyntax errors.Kind = \"HCL syntax error\"\nfunc IsStack(path string) (bool, error)\ntype Module struct{ ... }\n func ParseModules(path string) ([]Module, error)\ntype Source struct{ ... }\n func ParseSource(modsource string) (Source, error)" + tags = ["golang", "tf"] + id = "c5a8d204-0193-4beb-a0e5-28a0fbe798e3" +} diff --git a/tg/_test_mock.tf b/tg/_test_mock.tf new file mode 100644 index 000000000..100d150d8 --- /dev/null +++ b/tg/_test_mock.tf @@ -0,0 +1,16 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "tg" { + content = <<-EOT +package tg // import "github.com/terramate-io/terramate/tg" + +Package tg implements functions to deal with Terragrunt files. + +const ErrParsing errors.Kind = "parsing Terragrunt file" +type Module struct{ ... } +type Modules []*Module + func ScanModules(rootdir string, dir project.Path, trackDependencies bool) (Modules, error) +EOT + + filename = "${path.module}/mock-tg.ignore" +} diff --git a/tg/stack.tm.hcl b/tg/stack.tm.hcl new file mode 100644 index 000000000..8efee2204 --- /dev/null +++ b/tg/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package tg // import \"github.com/terramate-io/terramate/tg\"" + description = "package tg // import \"github.com/terramate-io/terramate/tg\"\n\nPackage tg implements functions to deal with Terragrunt files.\n\nconst ErrParsing errors.Kind = \"parsing Terragrunt file\"\ntype Module struct{ ... }\ntype Modules []*Module\n func ScanModules(rootdir string, dir project.Path, trackDependencies bool) (Modules, error)" + tags = ["golang", "tg"] + id = "84d2ad63-38a0-408f-9d11-3b95168d9484" +} diff --git a/versions/_test_mock.tf b/versions/_test_mock.tf new file mode 100644 index 000000000..8b4347117 --- /dev/null +++ b/versions/_test_mock.tf @@ -0,0 +1,15 @@ +// TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT + +resource "local_file" "versions" { + content = <<-EOT +package versions // import "github.com/terramate-io/terramate/versions" + +Package versions provide helper functions for version constraint matching. + +const ErrCheck errors.Kind = "version check error" +func Check(version string, constraint string, allowPrereleases bool) error +func Match(version, constraint string, allowPrereleases bool) (bool, error) +EOT + + filename = "${path.module}/mock-versions.ignore" +} diff --git a/versions/stack.tm.hcl b/versions/stack.tm.hcl new file mode 100644 index 000000000..e81d0b864 --- /dev/null +++ b/versions/stack.tm.hcl @@ -0,0 +1,9 @@ +// Copyright 2024 Terramate GmbH +// SPDX-License-Identifier: MPL-2.0 + +stack { + name = "package versions // import \"github.com/terramate-io/terramate/versions\"" + description = "package versions // import \"github.com/terramate-io/terramate/versions\"\n\nPackage versions provide helper functions for version constraint matching.\n\nconst ErrCheck errors.Kind = \"version check error\"\nfunc Check(version string, constraint string, allowPrereleases bool) error\nfunc Match(version, constraint string, allowPrereleases bool) (bool, error)" + tags = ["golang", "versions"] + id = "a885a9ed-eb00-4f79-b342-c7239ebfb5bd" +}