Skip to content

Commit 6c96480

Browse files
authored
Merge pull request #71 from wallix/develop
docs: update README and add new usage examples
2 parents 933b7f4 + 13bc6b2 commit 6c96480

File tree

11 files changed

+888
-13
lines changed

11 files changed

+888
-13
lines changed

Makefile

Lines changed: 79 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,83 @@
1+
# Define variables for maintainability
2+
PROVIDER_NAME := wallix-bastion
3+
PROVIDER_VERSION := 1.0.0
4+
# The go build output binary name
5+
BINARY_NAME := terraform-provider-$(PROVIDER_NAME)
16

2-
default: install
7+
# Get the version from git, defaulting to "dev"
8+
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
9+
10+
# Use a -ldflags string for versioning during compilation
11+
LDFLAGS_STRING := "-X main.version=$(VERSION)"
12+
13+
.PHONY: build install test testacc test-coverage fmt lint vet clean setup-dev docs build-all test-all
14+
15+
# Default target
16+
default: build
17+
18+
# Build the provider
19+
# This target now includes version information from git via LDFLAGS
20+
build:
21+
go build -ldflags=$(LDFLAGS_STRING) -o $(BINARY_NAME)
22+
23+
# Build for all platforms
24+
build-all:
25+
mkdir -p dist
26+
GOOS=darwin GOARCH=amd64 go build -ldflags=$(LDFLAGS_STRING) -o dist/$(BINARY_NAME)_darwin_amd64
27+
GOOS=darwin GOARCH=arm64 go build -ldflags=$(LDFLAGS_STRING) -o dist/$(BINARY_NAME)_darwin_arm64
28+
GOOS=linux GOARCH=amd64 go build -ldflags=$(LDFLAGS_STRING) -o dist/$(BINARY_NAME)_linux_amd64
29+
GOOS=linux GOARCH=arm64 go build -ldflags=$(LDFLAGS_STRING) -o dist/$(BINARY_NAME)_linux_arm64
30+
GOOS=windows GOARCH=amd64 go build -ldflags=$(LDFLAGS_STRING) -o dist/$(BINARY_NAME)_windows_amd64.exe
31+
32+
# Install locally for development
33+
# This target is now cross-platform, automatically detecting your OS and architecture
34+
install: build
35+
# Use the Go environment variables directly to create the correct plugin path
36+
mkdir -p ~/.terraform.d/plugins/terraform.local/local/$(PROVIDER_NAME)/$(PROVIDER_VERSION)/$(shell go env GOOS)_$(shell go env GOARCH)
37+
# Copy the binary to the correct location
38+
cp $(BINARY_NAME) ~/.terraform.d/plugins/terraform.local/local/$(PROVIDER_NAME)/$(PROVIDER_VERSION)/$(shell go env GOOS)_$(shell go env GOARCH)/
39+
40+
# Run unit tests
41+
test:
42+
go test -v ./...
43+
44+
# Run tests with coverage
45+
test-coverage:
46+
go test -v -coverprofile=coverage.out ./...
47+
go tool cover -html=coverage.out -o coverage.html
348

4-
.PHONY: install testacc
5-
# Install to use dev_overrides in provider_installation of Terraform
6-
install:
7-
go install
849
# Run acceptance tests
950
testacc:
10-
cd bastion ; TF_ACC=1 go test -v --timeout 0 -coverprofile=../coverage.out $(TESTARGS)
11-
go tool cover -html=coverage.out
51+
TF_ACC=1 go test -v ./bastion -timeout 120m
52+
53+
# Run all tests
54+
test-all: test testacc
55+
56+
# Format code
57+
fmt:
58+
go fmt ./...
59+
terraform fmt -recursive examples/
60+
61+
# Run linters
62+
lint:
63+
golangci-lint run
64+
65+
# Run go vet
66+
vet:
67+
go vet ./...
68+
69+
# Clean build artifacts
70+
clean:
71+
rm -f $(BINARY_NAME)
72+
rm -rf dist/
73+
rm -f coverage.out coverage.html
74+
75+
# Setup development environment
76+
setup-dev:
77+
go mod download
78+
go mod tidy
79+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
80+
81+
# Generate documentation
82+
docs:
83+
go generate ./...

README.md

Lines changed: 270 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,279 @@
1-
# terraform-provider-wallix-bastion
1+
# Terraform Provider for Wallix Bastion
2+
3+
![Wallix Logo](https://raw.githubusercontent.com/wallix/terraform-provider-wallix-bastion/main/LOGO_WALLIX_2024_black+orange.png)
4+
5+
A Terraform provider for managing Wallix Bastion resources
6+
7+
[![Go Report Card](https://goreportcard.com/badge/github.com/wallix/terraform-provider-wallix-bastion)](https://goreportcard.com/report/github.com/wallix/terraform-provider-wallix-bastion)
8+
[![License](https://img.shields.io/badge/License-MPL%202.0-blue.svg)](https://opensource.org/licenses/MPL-2.0)
9+
[![Terraform Registry](https://img.shields.io/badge/terraform-registry-623CE4.svg)](https://registry.terraform.io/providers/wallix/wallix-bastion/latest)
10+
11+
## Overview
12+
13+
The Terraform Wallix Bastion provider allows you to manage Wallix Bastion resources such as users, groups, authorizations, and more through Infrastructure as Code.
214

315
## Requirements
416

5-
- [Terraform](https://www.terraform.io/downloads.html)
17+
- [Terraform](https://www.terraform.io/downloads.html) >= 1.0
18+
- [Go](https://golang.org/doc/install) `v1.22` or `v1.23` (for development)
19+
- [Terraform](https://www.terraform.io/downloads.html) >= 1.0
20+
21+
- [Go](https://golang.org/doc/install) `v1.22` or `v1.23` (for development)
22+
23+
### From Terraform Registry
24+
25+
```hcl
26+
terraform {
27+
required_providers {
28+
wallix-bastion = {
29+
source = "wallix/wallix-bastion"
30+
version = "~> 0.14.0"
31+
}
32+
}
33+
}
34+
35+
provider "wallix-bastion" {
36+
ip = "your-bastion-host"
37+
user = "<user>"
38+
token = "<your-api-token>"
39+
}
40+
```
41+
42+
### Local Development Installation
43+
44+
```bash
45+
# Clone the repository
46+
git clone https://github.com/wallix/terraform-provider-wallix-bastion.git
47+
cd terraform-provider-wallix-bastion
48+
49+
# Build and install locally
50+
make install
51+
```
52+
53+
## Building the Provider
54+
55+
### Prerequisites
56+
57+
Ensure you have the following installed:
58+
59+
- Go 1.22 or 1.23
60+
- Make
61+
- Git
62+
63+
### Build Commands
64+
65+
```bash
66+
# Build the provider
67+
make build
68+
69+
# Build for all platforms
70+
make build-all
71+
72+
# Clean build artifacts
73+
make clean
74+
```
75+
76+
### Development Build
77+
78+
```bash
79+
# Install development dependencies
80+
go mod download
81+
82+
# Format code
83+
make fmt
84+
85+
# Run linters
86+
make lint
87+
88+
# Build development version
89+
go build -o terraform-provider-wallix-bastion
90+
```
91+
92+
## Testing
93+
94+
### Running Unit Tests
95+
96+
```bash
97+
# Run all tests
98+
make test
99+
100+
# Run tests with coverage
101+
make test-coverage
102+
103+
# Run specific test
104+
go test -v ./bastion -run TestAccResourceAuthorization_basic
105+
```
106+
107+
### Running Acceptance Tests
108+
109+
Acceptance tests require a running Wallix Bastion instance.
110+
111+
```bash
112+
# Set environment variables
113+
export WALLIX_BASTION_IP="your-bastion-host"
114+
export WALLIX_BASTION_TOKEN="<your-api-token>"
115+
export WALLIX_BASTION_API_VERSION="v3.12"
116+
117+
# Run acceptance tests
118+
make testacc
119+
120+
# Run specific acceptance test
121+
TF_ACC=1 go test -v ./bastion -run TestAccResourceAuthorization_sessionSharing
122+
```
123+
124+
### Test Environment Setup
125+
126+
1. **Set up test environment variables:**
6127

7-
### In addition to develop
128+
```bash
129+
export WALLIX_BASTION_HOST="your-test-bastion"
130+
export WALLIX_BASTION_TOKEN="<your-test-token>"
131+
export WALLIX_BASTION_API_VERSION="v3.8"
132+
export TF_ACC=1
133+
```
8134

9-
- [Go](https://golang.org/doc/install) `v1.22` or `v1.23`
135+
2. **Create test configuration:**
10136

11-
### Special Thanks
137+
```bash
138+
# Copy example configuration
139+
cp examples/authorization_test.tf test.tf
12140

13-
We would like to Greatly thanks:
141+
# Edit with your test values
142+
vim test.tf
143+
```
144+
145+
3. **Run manual tests:**
146+
147+
```bash
148+
terraform init
149+
terraform plan
150+
terraform apply
151+
terraform destroy
152+
```
153+
154+
## Local Development Workflow
155+
156+
### 1. Setup Development Environment
157+
158+
```bash
159+
# Clone and setup
160+
git clone https://github.com/wallix/terraform-provider-wallix-bastion.git
161+
cd terraform-provider-wallix-bastion
162+
163+
# Install dependencies
164+
go mod download
165+
go mod tidy
166+
167+
# Setup pre-commit hooks (optional)
168+
make setup-dev
169+
```
170+
171+
### 2. Make Changes
172+
173+
```bash
174+
# Create feature branch
175+
git checkout -b feature/your-feature-name
176+
177+
# Make your changes
178+
# ...
179+
180+
# Format and lint
181+
make fmt
182+
make lint
183+
184+
# Run tests
185+
make test
186+
```
187+
188+
### 3. Test Locally
189+
190+
```bash
191+
# Build and install locally
192+
make install
193+
194+
# Test with your Terraform configuration
195+
cd examples/
196+
terraform init
197+
terraform plan
198+
```
199+
200+
### 4. Submit Changes
201+
202+
```bash
203+
# Run full test suite
204+
make test-all
205+
206+
# Commit changes
207+
git add .
208+
git commit -m "feat: your feature description"
209+
git push origin feature/your-feature-name
210+
211+
# Create pull request
212+
```
213+
214+
## Makefile Commands
215+
216+
```bash
217+
# Build commands
218+
# Quality commands
219+
make fmt # Format Go code
220+
make lint # Run linters
221+
make vet # Run go vet
222+
# Quality commands
223+
make fmt # Format Go code
224+
make lint # Run linters
225+
make vet # Run go vet
226+
227+
# Test commands
228+
make test # Run unit tests
229+
make test-coverage # Run tests with coverage
230+
make testacc # Run acceptance tests
231+
make test-all # Run all tests
232+
233+
# Development commands
234+
make clean # Clean build artifacts
235+
make setup-dev # Setup development environment
236+
make docs # Generate documentation
237+
```
238+
239+
## Documentation
240+
241+
- [Provider Documentation](https://registry.terraform.io/providers/wallix/wallix-bastion/latest/docs)
242+
- [API Documentation](https://docs.wallix.com/)
243+
- [Examples](./examples/)
244+
245+
## Contributing
246+
247+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
248+
249+
1. Fork the repository
250+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
251+
3. Make your changes and add tests
252+
4. Run the test suite (`make test-all`)
253+
5. Commit your changes (`git commit -m 'Add amazing feature'`)
254+
6. Push to the branch (`git push origin feature/amazing-feature`)
255+
7. Open a Pull Request
256+
257+
## Version Compatibility
258+
259+
| Provider Version | Terraform Version | Go Version | Wallix Bastion API |
260+
|------------------|-------------------|------------|-------------------|
261+
| >= 0.14.0 | >= 1.0 | 1.22-1.23 | v3.8, v3.12 |
262+
| 0.13.x | >= 0.14 | 1.19-1.21 | v3.3, v3.6 |
263+
264+
## License
265+
266+
This project is licensed under the Mozilla Public License 2.0 - see the [LICENSE](LICENSE) file for details.
267+
268+
## Special Thanks
269+
270+
We would like to greatly thanks:
14271

15272
- [Claranet](https://www.claranet.fr/) for their great work on this provider!
273+
- The Terraform community for their continuous support and contributions
274+
275+
## Support
276+
277+
- 📖 [Documentation](https://registry.terraform.io/providers/wallix/wallix-bastion/latest/docs)
278+
- 🐛 [Issue Tracker](https://github.com/wallix/terraform-provider-wallix-bastion/issues)
279+
- 💬 [Discussions](https://github.com/wallix/terraform-provider-wallix-bastion/discussions)
68.8 KB
Loading

0 commit comments

Comments
 (0)