Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* SPDX-FileCopyrightText: 2025 Pexip AS
*
* SPDX-License-Identifier: Apache-2.0
*/

<component name="ProjectRunConfigurationManager">
<configuration default="false" name="TestRegisterDNSServerWithInfinity in github.com/pexip/go-infinity-sdk/v38" type="GoTestRunConfiguration" factoryName="Go Test" nameIsGenerated="true">
<module name="go-inifinity-sdk" />
<working_directory value="$PROJECT_DIR$/../go-inifinity-sdk" />
<envs>
<env name="INFINITY_PASSWORD" value="admin" />
<env name="INFINITY_URL" value="https://dev-manager.dev.pexip.network" />
<env name="INFINITY_USERNAME" value="admin" />
</envs>
<kind value="PACKAGE" />
<package value="github.com/pexip/go-infinity-sdk/v38" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<framework value="gotest" />
<pattern value="^\QTestRegisterDNSServerWithInfinity\E$" />
<method v="2" />
</configuration>
</component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* SPDX-FileCopyrightText: 2025 Pexip AS
*
* SPDX-License-Identifier: Apache-2.0
*/

<component name="ProjectRunConfigurationManager">
<configuration default="false" name="TestRegisterWorkWithInfinity in github.com/pexip/go-infinity-sdk/v38" type="GoTestRunConfiguration" factoryName="Go Test" nameIsGenerated="true">
<module name="go-inifinity-sdk" />
<working_directory value="$PROJECT_DIR$/../go-inifinity-sdk" />
<envs>
<env name="INFINITY_PASSWORD" value="admin" />
<env name="INFINITY_URL" value="https://dev-manager.dev.pexip.network" />
<env name="INFINITY_USERNAME" value="admin" />
</envs>
<kind value="PACKAGE" />
<package value="github.com/pexip/go-infinity-sdk/v38" />
<directory value="$PROJECT_DIR$" />
<filePath value="$PROJECT_DIR$" />
<framework value="gotest" />
<pattern value="^\QTestRegisterWorkWithInfinity\E$" />
<method v="2" />
</configuration>
</component>
57 changes: 57 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Overview

This is a Terraform provider for Pexip Infinity that allows managing Pexip Infinity infrastructure through Terraform. The provider uses the Pexip go-infinity-sdk v38 to interact with Pexip Infinity Manager APIs.

## Development Commands

### Building and Installing
- `make install` - Build and install the provider locally to `~/.terraform.d/plugins`
- `make build` - Build the provider binary to `dist/` directory
- `make build-dev` - Build directly to Terraform plugins directory for development

### Testing
- `make test` - Run unit tests (tagged as `unit`)
- `make testacc` - Run Terraform acceptance tests (sets `TF_ACC=true`, tagged as `integration`)
- `make check` - Run linting and tests together

### Code Quality
- `make lint` - Run golangci-lint with specific checks (govet, ineffassign, staticcheck, deadcode, unused)
- `make fmt` - Format Go code using `go fmt`
- `make sec` - Run security analysis with gosec

### Local Development Setup
Requires creating `~/.terraformrc` with dev_overrides pointing to local plugin directory as shown in README.md.

## Architecture

### Provider Structure
- **Main entry point**: `main.go` - Standard Terraform plugin serve setup
- **Provider core**: `internal/provider/provider.go` - Defines PexipProvider with Infinity client integration
- **Authentication**: Uses basic auth with username/password against Pexip Infinity Manager API
- **Concurrency**: Provider includes mutex for thread-safe operations

### Resources and Data Sources
- **InfinityNodeResource**: Manages Pexip Infinity nodes
- **InfinityManagerConfigDataSource**: Generates bootstrap configuration for Pexip Infinity Manager
- Models are defined in separate files (e.g., `infinity_manager_config_model.go`)

### Key Dependencies
- Terraform Plugin Framework v1.15.0 (newer framework, not SDK v2)
- Pexip go-infinity-sdk v38 for API interactions
- Custom validators in `internal/provider/validators/` for IP addresses and URLs

### Directory Structure
- `internal/provider/` - Core provider implementation
- `internal/helpers/` - Utility functions and hashing
- `internal/log/` - Terraform-specific logging setup
- `testdata/` - Terraform configuration files for testing
- `example/` - Complete example Terraform configurations

### Testing Patterns
- Unit tests use `unit` build tag
- Acceptance tests use `integration` build tag and require `TF_ACC=true`
- Test files follow `*_test.go` naming convention
61 changes: 61 additions & 0 deletions GEMINI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Project Overview

This project is a Terraform provider for Pexip Infinity. It allows users to manage their Pexip Infinity infrastructure as code, covering a wide range of features from basic node configuration to integrations with Microsoft 365 and Google Workspace. The provider is written in Go and uses the Pexip Go SDK to interact with the Pexip Infinity API.

## Key Technologies

* **Go:** The programming language used to develop the Terraform provider.
* **Terraform:** The infrastructure as code tool that this provider plugs into.
* **Pexip Infinity API:** The API that this provider communicates with to manage Pexip Infinity resources.

## Architecture

The project follows the standard structure for a Terraform provider. The core logic is located in the `internal/provider` directory, with the main entry point being `main.go`. The provider defines a set of resources that correspond to Pexip Infinity objects, such as conferences, locations, and worker VMs.

# Building and Running

The project uses a `Makefile` to streamline the development process. Here are the key commands:

* **Build the provider:**
```bash
make build
```

* **Run unit tests:**
```bash
make test
```

* **Run acceptance tests (requires a Pexip Infinity environment):**
```bash
make testacc
```

* **Lint the code:**
```bash
make lint
```

* **Format the code:**
```bash
make fmt
```

* **Install the provider locally:**
```bash
make install
```

# Development Conventions

## Coding Style

The project follows standard Go coding conventions. Code should be formatted with `gofmt` before committing.

## Testing

The project has both unit and acceptance tests. Unit tests are located alongside the code they test and can be run with `make test`. Acceptance tests require a running Pexip Infinity instance and are located in the `internal/provider` directory. They can be run with `make testacc`.

## Contribution Guidelines

Contributions are welcome. Please see the `CONTRIBUTING.md` file for more details.
65 changes: 65 additions & 0 deletions contrib/delete-workflow-runs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env bash
set -euo pipefail

# Delete GitHub Actions runs older than a given age
# Usage: ./delete-old-runs.sh OWNER/REPO MINUTES [--dry-run]
#
# Examples:
# ./delete-old-runs.sh myorg/myrepo 120
# ./delete-old-runs.sh myorg/myrepo 60 --dry-run

usage() {
echo "Usage: $0 OWNER/REPO MINUTES [--dry-run]"
exit 1
}

REPO="${1:-}"; shift || true
AGE_MINUTES="${1:-}"; shift || true
DRY_RUN="${1:-}"

[[ -z "${REPO}" || -z "${AGE_MINUTES}" ]] && usage
if ! [[ "${AGE_MINUTES}" =~ ^[0-9]+$ ]]; then
echo "MINUTES must be an integer" >&2
exit 1
fi

echo "Fetching runs for ${REPO} and deleting those older than ${AGE_MINUTES} minutes..."
[[ "${DRY_RUN:-}" == "--dry-run" ]] && echo "Dry run mode: will only print IDs and not delete."

# We fetch a large page (up to 1000). Increase if needed or loop over pages via gh api.
# Fields: databaseId (run ID), createdAt (RFC3339), status
JQ_FILTER="
.[]
| select(.status == \"completed\")
| select( (now - (.createdAt | fromdateiso8601)) > (${AGE_MINUTES} * 60) )
| .databaseId
"

# If your gh doesn't support `fromdateiso8601`/`now`, see fallback note below.
RUN_IDS="$(gh run list \
--repo "${REPO}" \
--limit 1000 \
--json databaseId,createdAt,status \
--jq "${JQ_FILTER}" || true)"

if [[ -z "${RUN_IDS}" ]]; then
echo "No runs to delete (either none found, or none older than ${AGE_MINUTES} minutes)."
exit 0
fi

COUNT=0
for ID in ${RUN_IDS}; do
if [[ "${DRY_RUN:-}" == "--dry-run" ]]; then
echo "[dry-run] Would delete run ID ${ID}"
else
echo "Deleting run ${ID}..."
gh api --silent --method DELETE "repos/${REPO}/actions/runs/${ID}"
fi
COUNT=$((COUNT + 1))
done

if [[ "${DRY_RUN:-}" == "--dry-run" ]]; then
echo "Dry run complete. ${COUNT} runs would have been deleted."
else
echo "✅ Deleted ${COUNT} runs older than ${AGE_MINUTES} minutes from ${REPO}."
fi
5 changes: 5 additions & 0 deletions example/gcp-infinity-manager/test-cert.pem.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
* SPDX-FileCopyrightText: 2025 Pexip AS
*
* SPDX-License-Identifier: Apache-2.0
*/
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/hashicorp/terraform-plugin-framework-validators v0.18.0
github.com/hashicorp/terraform-plugin-go v0.28.0
github.com/hashicorp/terraform-plugin-log v0.9.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0
github.com/hashicorp/terraform-plugin-testing v1.13.3
github.com/pexip/go-infinity-sdk/v38 v38.0.5
github.com/stretchr/testify v1.10.0
golang.org/x/crypto v0.40.0
Expand Down Expand Up @@ -40,6 +40,7 @@ require (
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.23.0 // indirect
github.com/hashicorp/terraform-json v0.25.0 // indirect
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0 // indirect
github.com/hashicorp/terraform-registry-address v0.3.0 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
github.com/hashicorp/yamux v0.1.2 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9T
github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0 h1:NFPMacTrY/IdcIcnUB+7hsore1ZaRWU9cnB6jFoBnIM=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.37.0/go.mod h1:QYmYnLfsosrxjCnGY1p9c7Zj6n9thnEE+7RObeYs3fA=
github.com/hashicorp/terraform-plugin-testing v1.13.3 h1:QLi/khB8Z0a5L54AfPrHukFpnwsGL8cwwswj4RZduCo=
github.com/hashicorp/terraform-plugin-testing v1.13.3/go.mod h1:WHQ9FDdiLoneey2/QHpGM/6SAYf4A7AZazVg7230pLE=
github.com/hashicorp/terraform-registry-address v0.3.0 h1:HMpK3nqaGFPS9VmgRXrJL/dzHNdheGVKk5k7VlFxzCo=
github.com/hashicorp/terraform-registry-address v0.3.0/go.mod h1:jRGCMiLaY9zii3GLC7hqpSnwhfnCN5yzvY0hh4iCGbM=
github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ=
Expand Down
4 changes: 1 addition & 3 deletions internal/provider/data_infinity_manager_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@
package provider

import (
"os"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"

Check failure on line 12 in internal/provider/data_infinity_manager_config_test.go

View workflow job for this annotation

GitHub Actions / Code Quality

import 'github.com/hashicorp/terraform-plugin-testing/helper/resource' is not allowed from list 'main' (depguard)
"github.com/pexip/go-infinity-sdk/v38"

"github.com/pexip/terraform-provider-pexip/internal/test"
)

func TestInfinityManagerConfig(t *testing.T) {
t.Parallel()
os.Setenv("TF_ACC", "1")

// Create a mock client and set up expectations
client := infinity.NewClientMock()
Expand Down
6 changes: 1 addition & 5 deletions internal/provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
package provider

import (
"os"
"testing"

"github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/hashicorp/terraform-plugin-go/tfprotov5"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"

Check failure on line 14 in internal/provider/provider_test.go

View workflow job for this annotation

GitHub Actions / Code Quality

import 'github.com/hashicorp/terraform-plugin-testing/helper/resource' is not allowed from list 'main' (depguard)
)

func getTestProtoV5ProviderFactories(client InfinityClient) map[string]func() (tfprotov5.ProviderServer, error) {
Expand All @@ -22,8 +21,5 @@
}

func TestMain(m *testing.M) {
if os.Getenv("TF_ACC") == "" {
os.Exit(m.Run())
}
resource.TestMain(m)
}
4 changes: 1 addition & 3 deletions internal/provider/resource_infinity_adfs_auth_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@
package provider

import (
"os"
"testing"

"github.com/pexip/go-infinity-sdk/v38/config"
"github.com/pexip/go-infinity-sdk/v38/types"
"github.com/stretchr/testify/mock"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"

Check failure on line 16 in internal/provider/resource_infinity_adfs_auth_server_test.go

View workflow job for this annotation

GitHub Actions / Code Quality

import 'github.com/hashicorp/terraform-plugin-testing/helper/resource' is not allowed from list 'main' (depguard)
"github.com/pexip/go-infinity-sdk/v38"

"github.com/pexip/terraform-provider-pexip/internal/test"
)

func TestInfinityADFSAuthServer(t *testing.T) {
t.Parallel()
_ = os.Setenv("TF_ACC", "1")

// Create a mock client and set up expectations
client := infinity.NewClientMock()
Expand Down
4 changes: 1 addition & 3 deletions internal/provider/resource_infinity_authentication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@

import (
"context"
"os"
"testing"

"github.com/pexip/go-infinity-sdk/v38/config"
"github.com/stretchr/testify/mock"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"

Check failure on line 16 in internal/provider/resource_infinity_authentication_test.go

View workflow job for this annotation

GitHub Actions / Code Quality

import 'github.com/hashicorp/terraform-plugin-testing/helper/resource' is not allowed from list 'main' (depguard)
"github.com/pexip/go-infinity-sdk/v38"

"github.com/pexip/terraform-provider-pexip/internal/test"
Expand Down Expand Up @@ -52,7 +51,6 @@

func TestInfinityAuthentication(t *testing.T) {
t.Parallel()
_ = os.Setenv("TF_ACC", "1")

client := infinity.NewClientMock()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@
package provider

import (
"os"
"testing"

"github.com/pexip/go-infinity-sdk/v38/config"
"github.com/pexip/go-infinity-sdk/v38/types"
"github.com/stretchr/testify/mock"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"

Check failure on line 16 in internal/provider/resource_infinity_automatic_participant_test.go

View workflow job for this annotation

GitHub Actions / Code Quality

import 'github.com/hashicorp/terraform-plugin-testing/helper/resource' is not allowed from list 'main' (depguard)
"github.com/pexip/go-infinity-sdk/v38"

"github.com/pexip/terraform-provider-pexip/internal/test"
)

func TestInfinityAutomaticParticipant(t *testing.T) {
t.Parallel()
_ = os.Setenv("TF_ACC", "1")

client := infinity.NewClientMock()

Expand Down
Loading
Loading