Skip to content

Commit 230137a

Browse files
committed
local dev
1 parent 515759b commit 230137a

File tree

6 files changed

+77
-19
lines changed

6 files changed

+77
-19
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
bin
2+
bin-plugin

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
# Contributing to the Atlas CLI plugin for Terraform's MongoDB Atlas Provider
22

33
WIP
4+
5+
## Building
6+
7+
You can build the binary plugin by running `make build`. You'll need to have Go installed. Then you can run directly the generated binary `./bin/binary terraform [command]` to test your changes.
8+
9+
## Using the plugin from the CLI
10+
11+
You can also use the plugin with your changes from the CLI by running: `make local` and following the instructions displayed.

GNUmakefile

Lines changed: 0 additions & 18 deletions
This file was deleted.

Makefile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
CLI_SOURCE_FILES?=./cmd/plugin
2+
CLI_BINARY_NAME?=binary
3+
CLI_DESTINATION=./bin/$(CLI_BINARY_NAME)
4+
MANIFEST_FILE?=./bin/manifest.yml
5+
WIN_MANIFEST_FILE?=./bin/manifest.windows.yml
6+
7+
GOLANGCI_VERSION=v1.63.4 # Also update golangci-lint GH action in code-health.yml when updating this version
8+
9+
.PHONY: build
10+
build: ## Generate the binary in ./bin
11+
@echo "==> Building plugin binary: $(CLI_BINARY_NAME)"
12+
go build -o $(CLI_DESTINATION) $(CLI_SOURCE_FILES)
13+
14+
.PHONY: tools
15+
tools: ## Install the dev tools (dependencies)
16+
@echo "==> Installing dev tools..."
17+
go telemetry off # disable sending telemetry data, more info: https://go.dev/doc/telemetry
18+
go install github.com/rhysd/actionlint/cmd/actionlint@latest
19+
go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
20+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin $(GOLANGCI_VERSION)
21+
22+
.PHONY: clean
23+
clean: ## Clean binary folders
24+
rm -rf ./bin ./bin-plugin
25+
26+
.PHONY: local
27+
local: clean build ## Allow to run the plugin locally
28+
@echo "==> Configuring plugin locally"
29+
VERSION=0.0.1-local GITHUB_REPOSITORY_OWNER=owner GITHUB_REPOSITORY_NAME=repo $(MAKE) generate-manifest
30+
@mkdir -p ./bin-plugin
31+
cp -r ./bin ./bin-plugin/atlas-cli-plugin-terraform
32+
@echo
33+
@echo "==> Plugin is ready to be used locally"
34+
@echo "run: export ATLAS_CLI_EXTRA_PLUGIN_DIRECTORY=./bin-plugin"
35+
@echo "then this command should show the plugin: atlas plugin list"
36+
37+
.PHONY: generate-all-manifests
38+
generate-all-manifests: generate-manifest generate-manifest-windows ## Generate all the manifest files
39+
40+
.PHONY: generate-manifest
41+
generate-manifest: ## Generate the manifest file for non-windows OSes
42+
@echo "==> Generating non-windows manifest file"
43+
@mkdir -p ./bin
44+
BINARY=$(CLI_BINARY_NAME) envsubst < manifest.template.yml > $(MANIFEST_FILE)
45+
46+
.PHONY: generate-manifest-windows
47+
generate-manifest-windows: ## Generate the manifest file for windows OSes
48+
@echo "==> Generating windows manifest file"
49+
CLI_BINARY_NAME="${CLI_BINARY_NAME}.exe" MANIFEST_FILE="$(WIN_MANIFEST_FILE)" $(MAKE) generate-manifest
50+
51+
.PHONY: help
52+
.DEFAULT_GOAL := help
53+
help:
54+
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
55+

cmd/plugin/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
func main() {
1212
terraformCmd := &cobra.Command{
1313
Use: "terraform",
14-
Short: "Root command of the Atlas CLI plugin for Terraform's MongoDB Atlas Provider",
14+
Short: "Utilities for Terraform's MongoDB Atlas Provider",
1515
Aliases: []string{"tf"},
1616
}
1717

manifest.template.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: atlas-cli-plugin-terraform
2+
description: Utilities for Terraform's MongoDB Atlas Provider
3+
version: $VERSION
4+
github:
5+
owner: $GITHUB_REPOSITORY_OWNER
6+
name: $GITHUB_REPOSITORY_NAME
7+
binary: $BINARY
8+
commands:
9+
terraform:
10+
description: Utilities for Terraform's MongoDB Atlas Provider
11+
tf:
12+
description: Alias for the terraform command

0 commit comments

Comments
 (0)