Skip to content

Commit

Permalink
Merge pull request #1 from lifeomic/update-contexts
Browse files Browse the repository at this point in the history
Make releaseable
  • Loading branch information
keeslinp authored Jan 5, 2022
2 parents 720350e + c5bc481 commit 912de89
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 12 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This GitHub action can publish assets for release when a tag is created.
# Currently its setup to run on any tag that matches the pattern "v*" (ie. v0.1.0).
#
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
# secret. If you would rather own your own GPG handling, please fork this action
# or use an alternative one for key handling.
#
# You will need to pass the `--batch` flag to `gpg` in your signing step
# in `goreleaser` to indicate this is being used in a non-interactive mode.
#
name: release
on:
push:
tags:
- 'v*'
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2.4.0
-
name: Unshallow
run: git fetch --prune --unshallow
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
-
name: Import GPG key
id: import_gpg
uses: hashicorp/ghaction-import-gpg@v2.1.0
env:
# These secrets will need to be configured for the repository:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.GPG_PRIVATE_KEY_PASSPHRASE }}
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2.8.0
with:
version: latest
args: release --rm-dist
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
# GitHub sets this automatically
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.terraform.lock.hcl
terraform.tfstate
terraform.tfstate.backup
dist
60 changes: 60 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Visit https://goreleaser.com for documentation on how to customize this
# behavior.
before:
hooks:
# this is just an example and not a requirement for provider building/publishing
- go mod tidy
builds:
- env:
# goreleaser does not work with CGO, it could also complicate
# usage by users in CI/CD systems like Terraform Cloud where
# they are unable to install libraries.
- CGO_ENABLED=0
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
ldflags:
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
goos:
- freebsd
- windows
- linux
- darwin
goarch:
- amd64
- '386'
- arm
- arm64
ignore:
- goos: darwin
goarch: '386'
binary: '{{ .ProjectName }}_v{{ .Version }}'
archives:
- format: zip
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
checksum:
extra_files:
- glob: 'terraform-registry-manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
algorithm: sha256
signs:
- artifacts: checksum
args:
# if you are using this in a GitHub action or some other automated pipeline, you
# need to pass the batch flag to indicate its not interactive.
- "--batch"
- "--local-user"
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
- "--output"
- "${signature}"
- "--detach-sign"
- "${artifact}"
release:
extra_files:
- glob: 'terraform-registry-manifest.json'
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
# If you want to manually examine the release before its live, uncomment this line:
# draft: true
changelog:
skip: true
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Terraform provider for the app-store-service. See docs/index.md for more info.
4 changes: 2 additions & 2 deletions appstore/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ type AppStoreClient struct {

func (client *AppStoreClient) gql(query string, variables map[string]interface{}) (*lambda.InvokeOutput, error) {
APP_STORE_ARN := "app-store-service:deployed"
return client.c.Invoke(context.TODO(), &lambda.InvokeInput{
return client.c.Invoke(context.Background(), &lambda.InvokeInput{
FunctionName: &APP_STORE_ARN,
Payload: gqlQuery(query, variables),
})
Expand Down Expand Up @@ -207,7 +207,7 @@ func (client *AppStoreClient) editAppStoreListing(id string, params appStoreCrea
}

func BuildAppStoreClient() (*AppStoreClient, error) {
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithSharedConfigProfile("lifeomic-dev"))
cfg, err := config.LoadDefaultConfig(context.Background(), config.WithSharedConfigProfile("lifeomic-dev"))
if err != nil {
return nil, err
}
Expand Down
29 changes: 29 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# <provider> Provider

This provider is for managing LifeOmic app store resources. Typically these applets are then published on the marketplace (marketplace provider is still under development). If you're working to use this provider for external applets, contact LifeOmic for assistance. A self-serve experience is under development.

The provider uses your local AWS config in order to authenticate. Support for token-based authentication with the public graphql-proxy will probably come in the future.

## Example Usage

```hcl
provider "appstore" {}
resource "applet" "example" {
provider = appstore
name = "Example Applet for App Store"
description = "This applet is created and managed using terraform"
author_display = "LifeOmic"
url = "applets.example.com/route/to/applet"
image = "applets.example.com/route/to/applet/icon.png"
}
```

## Argument Reference

* name: string
* description: string
* author_display: string
* url: string
* image: string

22 changes: 12 additions & 10 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Example of how to use the resource

terraform {
required_providers {
appstore = {
Expand All @@ -13,7 +15,7 @@ variable "name" {

variable "icons" {
type = list(object({
src = string
src = string
sizes = string
}))
}
Expand All @@ -22,27 +24,27 @@ variable "start_url" {
type = string
}

variable "description" {
variable "description" {
type = string
}

# Not the right name, just for testing
variable "url_base" {
type = string
type = string
default = "https://lifeapplets.dev.lifeomic.com" # The anxiety part should probably be separate
}

locals {
app_url = "${var.url_base}/anxiety"
}
app_url = "${var.url_base}/anxiety"
}

provider "appstore" {}

resource "applet" "anxiety" {
provider = appstore
name = var.name
description = var.description
provider = appstore
name = var.name
description = var.description
author_display = "LifeOmic"
url = "${local.app_url}/${var.start_url}"
image = "${local.app_url}/${var.icons[0].src}"
url = "${local.app_url}/${var.start_url}"
image = "${local.app_url}/${var.icons[0].src}"
}
8 changes: 8 additions & 0 deletions terraform-registry-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": 1,
"metadata": {
"protocol_versions": [
"5.0"
]
}
}

0 comments on commit 912de89

Please sign in to comment.