Skip to content

Commit

Permalink
Merge pull request #3 from atlassian/release-from-bitbucket
Browse files Browse the repository at this point in the history
Release from bitbucket
  • Loading branch information
aralozkaya authored Dec 3, 2024
2 parents 1e7cc0f + 2de6b86 commit d612dd0
Show file tree
Hide file tree
Showing 32 changed files with 590 additions and 214 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Terraform Provider release workflow.
name: Release

# This GitHub action creates a release when a tag that matches the pattern
# "v*" (e.g. v0.1.0) is created.
on:
push:
tags:
- 'v*'

# Releases need permissions to read and write the repository contents.
# GitHub considers creating releases and uploading assets as writing contents.
permissions:
contents: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
# Allow goreleaser to access older tag information.
fetch-depth: 0
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version-file: 'go.mod'
cache: true
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0
id: import_gpg
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@9ed2f89a662bf1735a48bc8557fd212fa902bebf # v6.1.0
with:
args: release --clean
env:
# GitHub sets the GITHUB_TOKEN secret automatically.
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
61 changes: 61 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Visit https://goreleaser.com for documentation on how to customize this
# behavior.
version: 2
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 HCP Terraform 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:
disable: true
76 changes: 38 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The process to run the provider in a local environment requires the following st

### 1. Requirements

This project requires the following programs to be installed on your computer, and their main executables to be
This project requires the following programs to be installed on your computer, and their main executables to be
available in your PATH:

- [Go](https://golang.org/doc/install) 1.22 (or higher, to build the provider plugin)
Expand All @@ -49,12 +49,12 @@ available in your PATH:
### 2. Cloning the repository

```bash
git clone git@bitbucket.org:jira-service-management/terraform-provider-atlassian-operations.git
git clone git@github.com:atlassian/terraform-provider-atlassian-operations.git
```

### 3. Compiling & Installing
_Make sure that go is already installed and the command is available on your path.
Check the [Go Documentation](https://go.dev/wiki/SettingGOPATH) for instructions on how to add the
Check the [Go Documentation](https://go.dev/wiki/SettingGOPATH) for instructions on how to add the
go executable to your path, if not already added._

While in the project directory, run the following commands:
Expand All @@ -70,7 +70,7 @@ go env GOPATH
```

### 4. Setting local overrides
This step is required for Terraform to use the plugin executable that you just compiled,
This step is required for Terraform to use the plugin executable that you just compiled,
instead of the one downloaded from the Terraform Registry.

* For macOS & Linux: Create a file called `.terraformrc` in your `$HOME` directory
Expand All @@ -80,9 +80,9 @@ Add the following content to the file:

```hcl
provider_installation {
# "/Users/<YOUR_USERNAME>/go/bin" is the path to the compiled provider ($GOPATH/bin).
# Change it accordingly if your configuration is different.
# "/Users/<YOUR_USERNAME>/go/bin" is the path to the compiled provider ($GOPATH/bin).
# Change it accordingly if your configuration is different.
dev_overrides {
# Replace <YOUR_USERNAME> with your username
"registry.terraform.io/atlassian/atlassian-operations" = "/Users/<YOUR_USERNAME>/go/bin"
Expand All @@ -101,27 +101,27 @@ provider_installation {

```hcl
terraform {
required_providers {
atlassian-operations = {
source = "registry.terraform.io/atlassian/atlassian-operations"
}
required_providers {
atlassian-operations = {
source = "registry.terraform.io/atlassian/atlassian-operations"
}
}
provider "atlassian-operations" {
cloud_id = "<YOUR_CLOUD_ID>"
domain_name="<YOUR_DOMAIN>" // e.g. domain.atlassian.net
email_address = "<YOUR_EMAIL_ADDRESS>" // e.g. [email protected]
token = "<YOUR_TOKEN_HERE>" // e.g. API token created in Atlassian account settings
}
data "atlassian-operations_user" "example" {
email_address = "[email protected]"
}
output "example" {
value = "data.atlassian-operations_user.example"
}
}
provider "atlassian-operations" {
cloud_id = "<YOUR_CLOUD_ID>"
domain_name="<YOUR_DOMAIN>" // e.g. domain.atlassian.net
email_address = "<YOUR_EMAIL_ADDRESS>" // e.g. [email protected]
token = "<YOUR_TOKEN_HERE>" // e.g. API token created in Atlassian account settings
}
data "atlassian-operations_user" "example" {
email_address = "[email protected]"
}
output "example" {
value = "data.atlassian-operations_user.example"
}
```

Instead of providing values in the _provider_ block directly, you can also set the following environment variables:
Expand All @@ -133,13 +133,13 @@ export ATLASSIAN_OPS_API_EMAIL_ADDRESS=YOUR_EMAIL_ADDRESS
export ATLASSIAN_OPS_API_TOKEN=YOUR_TOKEN
```

_If you do not want to debug the provider with a debugger, and would like to simply execute the Terraform file you
_If you do not want to debug the provider with a debugger, and would like to simply execute the Terraform file you
just created, you can skip the next part and jump directly to [Running Without Debugging](#53-running-without-debugging)_

#### 5.2. Enable Debugging

To enable debugging for the provider and make it connect to Delve before carrying on with the execution of the
instructions in the .tf file, you need to set the `debug` flag to `true`, via altering the `flag.BoolVar` statement in
To enable debugging for the provider and make it connect to Delve before carrying on with the execution of the
instructions in the .tf file, you need to set the `debug` flag to `true`, via altering the `flag.BoolVar` statement in
the `main.tf` file:

```go
Expand All @@ -148,25 +148,25 @@ import "flag"
// ...

func main() {
var debug bool
var debug bool

flag.BoolVar(&debug, "debug", true, "set to true to run the provider with support for debuggers like delve")
flag.Parse()
flag.BoolVar(&debug, "debug", true, "set to true to run the provider with support for debuggers like delve")
flag.Parse()

// Rest of the main.go file
// Rest of the main.go file
}
```
This will make the provider executable pause the execution and wait for a debugger to connect before proceeding.

With the default configuration, the provider binary is compiled **without debug information**.
To include the necessary debug information within the library, you need to build the provider with the
With the default configuration, the provider binary is compiled **without debug information**.
To include the necessary debug information within the library, you need to build the provider with the
-gcflags="all=-N -l" flag. Afterward, you can run and attach the process to the Delve debugger with the `dlv` command.

```bash
go build -gcflags="all=-N -l" .
dlv exec --accept-multiclient --continue --headless ./terraform_provider_jsm_ops -- -debug
```
_Most IDEs do building with debug flags and attaching to Delve debugger in the background automatically when the
_Most IDEs do building with debug flags and attaching to Delve debugger in the background automatically when the
debugger is run from within their UI._

When the provider executable is run with this configuration, it will output a message similar to the following:
Expand All @@ -181,7 +181,7 @@ Provider started. To attach Terraform CLI, set the TF_REATTACH_PROVIDERS environ
TF_REATTACH_PROVIDERS='{"registry.terraform.io/atlassian/atlassian-operations":{"Protocol":"grpc","ProtocolVersion":6,"Pid":47822,"Test":true,"Addr":{"Network":"unix","String":"/var/folders/5n/wcvl0l8d4nx15qz3jy9jn7wh0000gn/T/plugin3023012805"}}}'
```
Simply follow the instructions as they are prompted. Either set the `TF_REATTACH_PROVIDERS` environment variable in
Simply follow the instructions as they are prompted. Either set the `TF_REATTACH_PROVIDERS` environment variable in
your terminal, or prepend it to your every Terraform command.
* Set the environment variable:
Expand All @@ -195,7 +195,7 @@ TF_REATTACH_PROVIDERS=<_PROMPTED_STRING_AT_THE_DEBUG_CONSOLE_> terraform plan
TF_REATTACH_PROVIDERS=<_PROMPTED_STRING_AT_THE_DEBUG_CONSOLE_> terraform apply
```
More information on how to use Delve with Terraform can be found in the
More information on how to use Delve with Terraform can be found in the
[Terraform documentation](https://developer.hashicorp.com/terraform/plugin/debugging).
### 6. Running Acceptance Tests
Expand Down
12 changes: 12 additions & 0 deletions bitbucket-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,23 @@ definitions:
image: golangci/golangci-lint:v1.31.0
script:
- golangci-lint run -v
- step: &replicate-to-github
name: Replicate main branch to GitHub
script:
- git fetch --unshallow && git checkout main && git pull
- git remote rename origin bitbucket
- git remote add origin [email protected]:atlassian/terraform-provider-atlassian-operations.git
- git pull --rebase
- git checkout -b release-from-bitbucket
- git push --set-upstream origin release-from-bitbucket --force

pipelines:
default:
- parallel:
- step: *build
custom:
replicate-to-github:
- step: *replicate-to-github
pull-requests:
'**':
- step: *test
Expand Down
61 changes: 1 addition & 60 deletions docs/data-sources/schedule.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "atlassian-operations_schedule Data Source - terraform-provider-atlassian-operations"
page_title: "atlassian-operations_schedule Data Source - atlassian-operations"
subcategory: ""
description: |-
Schedule data source
Expand All @@ -24,64 +24,5 @@ Schedule data source
- `description` (String) The description of the schedule
- `enabled` (Boolean) Whether the schedule is enabled
- `id` (String) The ID of the schedule
- `rotations` (Attributes List) The rotations of the schedule (see [below for nested schema](#nestedatt--rotations))
- `team_id` (String) The ID of the team that owns the schedule
- `timezone` (String) The timezone of the schedule

<a id="nestedatt--rotations"></a>
### Nested Schema for `rotations`

Read-Only:

- `end_date` (String) The end date of the rotation
- `id` (String) The ID of the rotation
- `length` (Number) The length of the rotation
- `name` (String) The name of the rotation
- `participants` (Attributes List) The participants of the rotation (see [below for nested schema](#nestedatt--rotations--participants))
- `start_date` (String) The start date of the rotation
- `time_restriction` (Attributes) (see [below for nested schema](#nestedatt--rotations--time_restriction))
- `type` (String) The type of the rotation

<a id="nestedatt--rotations--participants"></a>
### Nested Schema for `rotations.participants`

Read-Only:

- `id` (String) The ID of the participant
- `type` (String) The type of the participant


<a id="nestedatt--rotations--time_restriction"></a>
### Nested Schema for `rotations.time_restriction`

Optional:

- `restriction` (Attributes) (see [below for nested schema](#nestedatt--rotations--time_restriction--restriction))
- `restrictions` (Attributes List) The restrictions of the time restriction (see [below for nested schema](#nestedatt--rotations--time_restriction--restrictions))

Read-Only:

- `type` (String) The type of the time restriction

<a id="nestedatt--rotations--time_restriction--restriction"></a>
### Nested Schema for `rotations.time_restriction.restriction`

Read-Only:

- `end_hour` (Number) The end hour of the restriction
- `end_min` (Number) The end minute of the restriction
- `start_hour` (Number) The start hour of the restriction
- `start_min` (Number) The start minute of the restriction


<a id="nestedatt--rotations--time_restriction--restrictions"></a>
### Nested Schema for `rotations.time_restriction.restrictions`

Read-Only:

- `end_day` (String) The end day of the restriction
- `end_hour` (Number) The end hour of the restriction
- `end_min` (Number) The end minute of the restriction
- `start_day` (String) The start day of the restriction
- `start_hour` (Number) The start hour of the restriction
- `start_min` (Number) The start minute of the restriction
Loading

0 comments on commit d612dd0

Please sign in to comment.