Skip to content

Commit ec2b092

Browse files
committed
feat: initial commit
first release
1 parent ce32763 commit ec2b092

60 files changed

Lines changed: 11801 additions & 2 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/devcontainer.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "Terraform Provider GitHubx",
3+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
4+
5+
"features": {
6+
"ghcr.io/devcontainers/features/git:1": {},
7+
"ghcr.io/devcontainers/features/github-cli:1": {},
8+
"ghcr.io/devcontainers/features/go:1": {},
9+
"ghcr.io/devcontainers/features/terraform:1": {}
10+
},
11+
12+
"customizations": {
13+
"vscode": {
14+
"extensions": [
15+
"davidanson.vscode-markdownlint",
16+
"golang.go",
17+
"hashicorp.terraform",
18+
"Gruntfuggly.todo-tree",
19+
"ms-azuretools.vscode-docker",
20+
"vscode-icons-team.vscode-icons",
21+
"ms-vscode.makefile-tools"
22+
],
23+
"settings": {
24+
"workbench.iconTheme": "vscode-icons",
25+
"go.useLanguageServer": true,
26+
"go.formatTool": "goimports",
27+
"go.lintTool": "golangci-lint",
28+
"go.lintOnSave": "package",
29+
"[go]": {
30+
"editor.formatOnSave": true,
31+
"editor.codeActionsOnSave": {
32+
"source.organizeImports": "explicit"
33+
}
34+
},
35+
"[terraform]": {
36+
"editor.formatOnSave": true
37+
},
38+
"terraform.format.enable": true,
39+
"terraform.languageServer.enable": true
40+
}
41+
}
42+
},
43+
44+
"postCreateCommand": ".devcontainer/scripts/postCreate.sh",
45+
46+
"remoteUser": "root",
47+
48+
"mounts": [
49+
"source=${localEnv:HOME}/.config/gh,target=/root/.config/gh,type=bind,consistency=cached"
50+
]
51+
}
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
#!/bin/bash
2+
# Don't use set -e to allow script to continue even if some steps fail
3+
# set -e
4+
5+
export DEBIAN_FRONTEND=noninteractive
6+
export GIT_TERMINAL_PROMPT=0
7+
8+
# Ensure we're running as root (no sudo needed)
9+
if [ "$(id -u)" -ne 0 ]; then
10+
echo "⚠️ Warning: Not running as root. Some operations may fail."
11+
fi
12+
13+
echo "🚀 Setting up Terraform Provider GitHubx development environment..."
14+
15+
# Install bash-completion if not already installed
16+
if ! command -v bash-completion &> /dev/null && [ ! -f /usr/share/bash-completion/bash_completion ]; then
17+
echo "📦 Installing bash-completion..."
18+
apt-get update -y && apt-get install -y bash-completion && rm -rf /var/lib/apt/lists/*
19+
fi
20+
21+
# Setup bashrc with aliases and history settings
22+
echo "⚙️ Configuring bash environment..."
23+
cat >> /root/.bashrc << 'BASHRC_EOF'
24+
25+
# Devcontainer bashrc configuration
26+
# History and completion settings
27+
28+
# Enable arrow key history navigation
29+
set -o emacs
30+
bind "\e[A": history-search-backward
31+
bind "\e[B": history-search-forward
32+
33+
# History settings
34+
HISTCONTROL=ignoredups:erasedups
35+
HISTSIZE=10000
36+
HISTFILESIZE=20000
37+
shopt -s histappend
38+
39+
# Save and reload history after each command
40+
PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
41+
42+
# Enable bash completion
43+
if [ -f /usr/share/bash-completion/bash_completion ]; then
44+
. /usr/share/bash-completion/bash_completion
45+
elif [ -f /etc/bash_completion ]; then
46+
. /etc/bash_completion
47+
fi
48+
49+
# Additional useful aliases
50+
alias ll='ls -alF'
51+
alias la='ls -A'
52+
alias l='ls -CF'
53+
alias ..='cd ..'
54+
alias ...='cd ../..'
55+
56+
# Git aliases
57+
alias gs='git status'
58+
alias ga='git add'
59+
alias gc='git commit'
60+
alias gp='git push'
61+
alias gl='git log --oneline --graph --decorate'
62+
63+
# Terraform aliases
64+
alias tf='terraform'
65+
alias tfi='terraform init'
66+
alias tfa='terraform apply'
67+
alias tfaa='terraform apply -auto-approve'
68+
alias tfp='terraform plan'
69+
alias tfd='terraform destroy'
70+
alias tfda='terraform destroy -auto-approve'
71+
72+
alias rmtl='rm -rf .terraform.lock.hcl'
73+
74+
BASHRC_EOF
75+
echo "✅ Bash environment configured"
76+
77+
# Display system information
78+
echo "📋 System Information:"
79+
uname -a
80+
if command -v go &> /dev/null; then
81+
echo "Go version: $(go version)"
82+
echo "Go path: $(go env GOPATH)"
83+
else
84+
echo "⚠️ Go not found - will be installed by devcontainer feature"
85+
fi
86+
87+
# Verify Terraform installation
88+
echo "🔧 Verifying Terraform..."
89+
if command -v terraform &> /dev/null; then
90+
echo "✅ Terraform installed: $(terraform version)"
91+
else
92+
echo "⚠️ Terraform not found - will be installed by devcontainer feature"
93+
fi
94+
95+
# Setup GitHub CLI authentication from host OS
96+
echo "🔧 Setting up GitHub CLI authentication..."
97+
if command -v gh &> /dev/null; then
98+
echo "✅ GitHub CLI installed: $(gh --version | head -n 1)"
99+
100+
# Ensure the config directory exists
101+
GH_CONFIG_DIR="/root/.config/gh"
102+
mkdir -p "${GH_CONFIG_DIR}"
103+
104+
# Check if host config is mounted (from devcontainer mount)
105+
# The devcontainer.json should mount ${localEnv:HOME}/.config/gh to /root/.config/gh
106+
if [ -d "${GH_CONFIG_DIR}" ] && [ -n "$(ls -A ${GH_CONFIG_DIR} 2>/dev/null)" ]; then
107+
echo "📁 Found mounted GitHub CLI config from host OS"
108+
# Ensure proper permissions (config files should be readable)
109+
chmod -R u+rw "${GH_CONFIG_DIR}" 2>/dev/null || true
110+
find "${GH_CONFIG_DIR}" -type f -name "*.yaml" -exec chmod 600 {} \; 2>/dev/null || true
111+
112+
# Verify authentication
113+
if gh auth status &> /dev/null; then
114+
echo "✅ GitHub CLI is authenticated (using host OS auth)"
115+
gh auth status 2>&1 | head -n 3 || true
116+
else
117+
echo "⚠️ GitHub CLI config found but not authenticated."
118+
echo " Please run 'gh auth login' on your host OS to authenticate."
119+
fi
120+
else
121+
echo "⚠️ GitHub CLI config not found at ${GH_CONFIG_DIR}"
122+
echo " The devcontainer should mount your host's ~/.config/gh directory."
123+
echo " If the mount failed, ensure you have authenticated with 'gh auth login' on your host OS."
124+
echo " You can also run 'gh auth login' inside the container, but it won't persist across rebuilds."
125+
126+
# Check if auth works anyway (might be using a different method)
127+
if gh auth status &> /dev/null; then
128+
echo "✅ GitHub CLI is authenticated (using alternative method)"
129+
gh auth status 2>&1 | head -n 3 || true
130+
fi
131+
fi
132+
else
133+
echo "⚠️ GitHub CLI not found"
134+
fi
135+
136+
# Install Terraform Plugin Framework docs generator
137+
echo "📚 Installing Terraform Plugin Framework documentation generator..."
138+
go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs@latest || echo "⚠️ Failed to install tfplugindocs (may retry later)"
139+
140+
# Verify Go tools (non-blocking, may not be installed yet)
141+
echo "🔧 Verifying Go tools..."
142+
command -v golangci-lint >/dev/null && echo "golangci-lint: $(golangci-lint version)" || echo "⚠️ golangci-lint not found"
143+
command -v goimports >/dev/null && echo "goimports: $(which goimports)" || echo "⚠️ goimports not found"
144+
command -v gopls >/dev/null && echo "gopls: $(which gopls)" || echo "⚠️ gopls not found"
145+
146+
# Download Go dependencies
147+
echo "📥 Downloading Go dependencies..."
148+
cd /workspaces/terraform-provider-githubx || cd /workspace
149+
go mod download || echo "⚠️ Go mod download failed (may retry later)"
150+
go mod verify || echo "⚠️ Go mod verify failed"
151+
152+
# Build the provider to verify everything works
153+
echo "🔨 Building provider..."
154+
go build -buildvcs=false -o terraform-provider-githubx || echo "⚠️ Build failed (may retry later)"
155+
156+
# Install provider locally for Terraform to use (only if build succeeded)
157+
echo "📦 Installing provider locally for Terraform..."
158+
if [ -f terraform-provider-githubx ]; then
159+
VERSION="0.1.0"
160+
PLATFORM="linux_amd64"
161+
PLUGIN_DIR="${HOME}/.terraform.d/plugins/registry.terraform.io/tfstack/githubx/${VERSION}/${PLATFORM}"
162+
mkdir -p "${PLUGIN_DIR}"
163+
cp terraform-provider-githubx "${PLUGIN_DIR}/" && echo "✅ Provider installed to ${PLUGIN_DIR}" || echo "⚠️ Failed to install provider"
164+
else
165+
echo "⚠️ Provider binary not found, skipping installation"
166+
fi
167+
168+
# Initialize Terraform in examples (non-blocking, may fail if variables needed)
169+
echo "🔧 Initializing Terraform examples..."
170+
for dir in examples/data-sources/*/ examples/resources/*/ examples/provider/; do
171+
if [ -f "${dir}data-source.tf" ] || [ -f "${dir}resource.tf" ] || [ -f "${dir}provider.tf" ] || [ -f "${dir}main.tf" ] || [ -f "${dir}"*.tf ]; then
172+
echo " Initializing ${dir}..."
173+
(cd "${dir}" && terraform init -upgrade -input=false > /dev/null 2>&1 && echo "${dir} initialized" || echo " ⚠️ ${dir} skipped (may need variables)")
174+
fi
175+
done
176+
177+
# Load .env file if it exists
178+
echo "🔐 Loading environment variables from .env file..."
179+
if [ -f /workspaces/terraform-provider-githubx/.env ]; then
180+
set -a
181+
source /workspaces/terraform-provider-githubx/.env
182+
set +a
183+
echo "✅ Environment variables loaded from .env"
184+
elif [ -f /workspace/.env ]; then
185+
set -a
186+
source /workspace/.env
187+
set +a
188+
echo "✅ Environment variables loaded from .env"
189+
else
190+
echo "⚠️ No .env file found. Create one from .env.example if needed."
191+
fi
192+
193+
echo ""
194+
echo "✅ Development environment setup complete!"
195+
echo ""
196+
echo "Available commands:"
197+
echo " make build - Build the provider"
198+
echo " make install - Install the provider"
199+
echo " make install-local - Install provider locally for Terraform testing"
200+
echo " make init-examples - Initialize Terraform in all examples"
201+
echo " make init-example - Initialize a specific example (EXAMPLE=path)"
202+
echo " make test - Run tests"
203+
echo " make fmt - Format code"
204+
echo " make docs - Generate documentation"
205+
echo ""
206+
echo "💡 The provider is already installed locally and examples are initialized!"
207+
echo " Navigate to any example directory and run 'terraform plan' or 'terraform apply'."

.env.example

Whitespace-only changes.

.github/CODE_OF_CONDUCT.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Code of Conduct
2+
3+
HashiCorp Community Guidelines apply to you when interacting with the community here on GitHub and contributing code.
4+
5+
Please read the full text at https://www.hashicorp.com/community-guidelines
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# DO NOT EDIT - This GitHub Workflow is managed by automation
2+
# https://github.com/hashicorp/terraform-devex-repos
3+
name: Issue Comment Triage
4+
5+
on:
6+
issue_comment:
7+
types: [created]
8+
9+
jobs:
10+
issue_comment_triage:
11+
runs-on: ubuntu-latest
12+
env:
13+
# issue_comment events are triggered by comments on issues and pull requests. Checking the
14+
# value of github.event.issue.pull_request tells us whether the issue is an issue or is
15+
# actually a pull request, allowing us to dynamically set the gh subcommand:
16+
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment-on-issues-only-or-pull-requests-only
17+
COMMAND: ${{ github.event.issue.pull_request && 'pr' || 'issue' }}
18+
GH_TOKEN: ${{ github.token }}
19+
steps:
20+
- name: 'Remove waiting-response on comment'
21+
run: gh ${{ env.COMMAND }} edit ${{ github.event.issue.html_url }} --remove-label waiting-response

.github/workflows/lock.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# DO NOT EDIT - This GitHub Workflow is managed by automation
2+
# https://github.com/hashicorp/terraform-devex-repos
3+
name: 'Lock Threads'
4+
5+
on:
6+
schedule:
7+
- cron: '43 20 * * *'
8+
9+
jobs:
10+
lock:
11+
runs-on: ubuntu-latest
12+
steps:
13+
# NOTE: When TSCCR updates the GitHub action version, update the template workflow file to avoid drift:
14+
# https://github.com/hashicorp/terraform-devex-repos/blob/main/modules/repo/workflows/lock.tftpl
15+
- uses: dessant/lock-threads@1bf7ec25051fe7c00bdd17e6a7cf3d7bfb7dc771 # v5.0.1
16+
with:
17+
github-token: ${{ github.token }}
18+
issue-inactive-days: '30'
19+
issue-lock-reason: resolved
20+
pr-inactive-days: '30'
21+
pr-lock-reason: resolved

.github/workflows/release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Terraform Provider release workflow.
2+
name: Release
3+
4+
on:
5+
workflow_run:
6+
workflows: ["Terraform Tag"]
7+
types:
8+
- completed
9+
branches:
10+
- main
11+
12+
# Releases need permissions to read and write the repository contents.
13+
# GitHub considers creating releases and uploading assets as writing contents.
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
goreleaser:
19+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
23+
with:
24+
# Allow goreleaser to access older tag information.
25+
fetch-depth: 0
26+
# Checkout the commit from the triggering workflow run
27+
ref: ${{ github.event.workflow_run.head_sha }}
28+
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
29+
with:
30+
go-version-file: 'go.mod'
31+
cache: true
32+
- name: Import GPG key
33+
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
34+
id: import_gpg
35+
with:
36+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
37+
passphrase: ${{ secrets.PASSPHRASE }}
38+
- name: Run GoReleaser
39+
uses: goreleaser/goreleaser-action@286f3b13b1b49da4ac219696163fb8c1c93e1200 # v6.0.0
40+
with:
41+
args: release --clean
42+
env:
43+
# GitHub sets the GITHUB_TOKEN secret automatically.
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}

.github/workflows/tag.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Terraform Tag
2+
on:
3+
workflow_run:
4+
workflows: ["Tests"]
5+
types:
6+
- completed
7+
branches:
8+
- main
9+
10+
permissions:
11+
contents: write
12+
jobs:
13+
terraform-tag:
14+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
15+
uses: actionsforge/actions/.github/workflows/terraform-tag.yml@main

0 commit comments

Comments
 (0)