Skip to content

Commit b78f0e0

Browse files
authored
chore: Initial plugin command (#7)
* initial Go files * readme info * typo * correct alias * add Terraform word in docs * fix linter * local dev * release initial commit * unify GHA names * enable release * fetch-depth: 0 * import gpg key * use master for release * typo * don't fix main * sign tag * sort help
1 parent ed4a91b commit b78f0e0

File tree

15 files changed

+238
-30
lines changed

15 files changed

+238
-30
lines changed

.github/workflows/issues.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
2-
name: Create JIRA ticket for new issues
2+
name: JIRA Tickets for GH Issues
33

4-
# Creates and updates jira tickets that sync with GitHub Issues events.
54
on:
65
issues:
76
types: [opened, reopened, closed]

.github/workflows/pull-request-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: pull-request-lint
1+
name: PR Linters
22

33
# Run validations over pull request titles while also adding appropriate labels.
44
on:

.github/workflows/release.yml

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,59 @@
11
name: 'New Release'
2+
run-name: 'Release ${{ inputs.version_number }}'
23

34
on:
45
workflow_dispatch:
6+
inputs:
7+
version_number:
8+
description: 'Version number (e.g. v1.0.0, v1.0.0-pre, v1.0.0-pre1)'
9+
required: true
510

611
jobs:
7-
release:
12+
13+
validate-inputs:
814
runs-on: ubuntu-latest
915
permissions: {}
1016
steps:
11-
- run: echo "WIP - Placeholder for release GHA"
17+
- name: Validation of version format
18+
run: echo "${{ inputs.version_number }}" | grep -P '^v\d+\.\d+\.\d+(-pre[A-Za-z0-9-]*)?$'
19+
20+
create-tag:
21+
needs: validate-inputs
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: write
25+
steps:
26+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
27+
- name: Get the latest commit SHA
28+
id: get-sha
29+
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
30+
- name: Create release tag
31+
uses: rickstaa/action-create-tag@a1c7777fcb2fee4f19b0f283ba888afa11678b72
32+
with:
33+
tag: ${{ inputs.version_number }}
34+
commit_sha: ${{ steps.get-sha.outputs.sha }}
35+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
36+
gpg_passphrase: ${{ secrets.PASSPHRASE }}
37+
38+
release:
39+
needs: create-tag
40+
runs-on: ubuntu-latest
41+
permissions:
42+
contents: write
43+
steps:
44+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
45+
with:
46+
ref: ${{ inputs.version_number }}
47+
fetch-depth: 0
48+
- name: Generate manifest files
49+
env:
50+
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
51+
GITHUB_REPOSITORY_NAME: ${{ github.event.repository.name }}
52+
VERSION: ${{ inputs.version_number }}
53+
run: make generate-all-manifests
54+
- name: Run GoReleaser
55+
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf
56+
with:
57+
args: release --clean
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/stale.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
2-
name: 'Stale issues and PRs handler'
2+
name: 'Stale PRs & Issues'
33

4-
# Handles stale github issues and pull requests.
54
on:
65
workflow_dispatch:
76
schedule:

.gitignore

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

.goreleaser.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
2+
project_name: atlas-cli-plugin-terraform
3+
4+
version: 2
5+
6+
builds:
7+
- id: "atlas-cli-plugin-terraform"
8+
main: ./cmd/plugin/main.go
9+
binary: ./binary
10+
11+
archives:
12+
- files:
13+
- src: './bin/manifest{{ if eq .Os "windows" }}.windows{{end}}.yml'
14+
dst: ./manifest.yml
15+
16+
release:
17+
prerelease: auto

CONTRIBUTING.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1-
# Contributing to Atlas CLI plugin for MongoDB Atlas Provider
1+
# 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}' | sort
55+

README.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
1-
# Atlas CLI plugin for MongoDB Atlas Provider
1+
# Atlas CLI plugin for Terraform's MongoDB Atlas Provider
22

33
[![Code Health](https://github.com/mongodb-labs/atlas-cli-plugin-terraform/actions/workflows/code-health.yml/badge.svg)](https://github.com/mongodb-labs/atlas-cli-plugin-terraform/actions/workflows/code-health.yml)
44

5-
This repository contains the Atlas CLI plugin for MongoDB Atlas Provider.
5+
This repository contains the Atlas CLI plugin for Terraform's MongoDB Atlas Provider.
66

77
WIP
8+
9+
## Installing
10+
11+
Install the [Atlas CLI](https://github.com/mongodb/mongodb-atlas-cli) if you haven't done it yet.
12+
13+
Install the plugin by running:
14+
```bash
15+
atlas plugin install github.com/mongodb-labs/atlas-cli-plugin-terraform
16+
```
17+
18+
## Usage
19+
20+
21+
## Contributing
22+
23+
See our [CONTRIBUTING.md](CONTRIBUTING.md) guide.
24+
25+
## License
26+
27+
MongoDB Atlas CLI is released under the Apache 2.0 license. See [LICENSE.md](LICENSE.md)

0 commit comments

Comments
 (0)