Skip to content

Commit

Permalink
Merge pull request #35 from kristofferahl/fix/channel-removals
Browse files Browse the repository at this point in the history
Fix: Removing channels
  • Loading branch information
kristofferahl committed Feb 23, 2024
2 parents 9999319 + 05ae083 commit 922a242
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.19
- name: Set up Goreleaser
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Test
run: ./run test
- name: Intergration Test
run: ./run docker test-integration
run: ./run dev test-integration
if: env.HEALTHCHECKSIO_API_KEY != ''
env:
HEALTHCHECKSIO_API_KEY: ${{ secrets.HEALTHCHECKSIO_API_KEY }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ crash.log
dist/
provider-version
generated.tf
dev.tfrc
bin/
13 changes: 13 additions & 0 deletions docs/guides/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ page_title: "Development"
./run <command> [<arg1> <arg2> ...]
```

## Running commands - in dev mode

This is useful to test the provider during development.
Using `./run dev ...` will:

- build the provider (go build .)
- setup overrides for provider installation (see dev.tfrc)
- run the command as specified

```bash
./run dev <command> [<arg1> <arg2> ...]
```

## Running commands - in docker

Most commands can also be executed using docker. Simply run the commands like below.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.19

require (
github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1
github.com/kristofferahl/go-healthchecksio v1.4.0
github.com/kristofferahl/go-healthchecksio/v2 v2.0.0
)

require (
Expand Down
5 changes: 3 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/franela/goblin v0.0.0-20211003143422-0a4f594942bf h1:NrF81UtW8gG2LBGkXFQFqlfNnvMt9WdB46sfdJY4oqc=
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
Expand Down Expand Up @@ -78,8 +79,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kristofferahl/go-healthchecksio v1.4.0 h1:H1BDESBvoQHB3Ht4XjkkQQqlPeH6OUnt+uf0QnYTU80=
github.com/kristofferahl/go-healthchecksio v1.4.0/go.mod h1:Y6ptmTrDSCGukP22zlbddM4KGwnOqMjT4itv++OIX6M=
github.com/kristofferahl/go-healthchecksio/v2 v2.0.0 h1:oNkNyiDbknpr8n2feTKgNmcG/rX+TJqHzdzsQUoM3PU=
github.com/kristofferahl/go-healthchecksio/v2 v2.0.0/go.mod h1:unMUgh3Psyhde35V3I5dr1S6x7CHQb2ydwESAU52q9I=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
Expand Down
2 changes: 1 addition & 1 deletion healthchecksio/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package healthchecksio
import (
"log"

"github.com/kristofferahl/go-healthchecksio"
"github.com/kristofferahl/go-healthchecksio/v2"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion healthchecksio/data_source_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"log"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/kristofferahl/go-healthchecksio"
"github.com/kristofferahl/go-healthchecksio/v2"
)

func dataSourceHealthcheckChannel() *schema.Resource {
Expand Down
2 changes: 1 addition & 1 deletion healthchecksio/resource_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/kristofferahl/go-healthchecksio"
"github.com/kristofferahl/go-healthchecksio/v2"
)

func resourceHealthcheck() *schema.Resource {
Expand Down
36 changes: 32 additions & 4 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ run_help() {
commands:
build Build the provider
dev Run a command in dev mode (example: ./run dev examples full)
docker Run a command in docker (example: ./run docker test)
examples Run examples
test Run tests
Expand Down Expand Up @@ -127,6 +128,34 @@ run_release() {
${GORELEASER_BIN:?} --rm-dist
}

run_dev() {
log WAR 'Running in dev mode...'

log INF "Building provider..."
go build .

log INF "Generating provider install instructions..."
echo "provider_installation {
dev_overrides {
\"registry.terraform.io/kristofferahl/healthchecksio\" = \"${PWD:?}\"
}
direct {}
}" >dev.tfrc

log INF "Setting up environment..."
export TF_CLI_CONFIG_FILE=${PWD:?}/dev.tfrc
export SKIP_INIT=true

local command="${1:-}"
shift || true

case "${command}" in
examples) run_examples "$@" ;;
test-integration) run_test_integration "$@" ;;
*) log ERR "Unknown dev command: ${command}" && exit 1 ;;
esac
}

run_examples() {
[ "${HEALTHCHECKSIO_API_KEY:?'Environment variable "HEALTHCHECKSIO_API_KEY" is required'}" ]

Expand All @@ -141,12 +170,11 @@ run_examples() {

log INF "Example: $(basename "${d:?}") (${d:?})"

install_plugin "${d:?}"
cd "${d:?}" || exit 1

[[ "$(basename "${d:?}")" != "self-hosted" ]] && generate_provider_config_file

terraform init -upgrade
[[ ${SKIP_INIT:-false} == false ]] && terraform init -upgrade
terraform apply
fi
done
Expand All @@ -168,12 +196,11 @@ run_test_integration() {

rm -rf "${d:?}/terraform.tfstate" || true
rm -rf "${d:?}/terraform.tfstate.backup" || true
install_plugin "${d:?}"
cd "${d:?}" || exit 1

generate_provider_config_file

terraform init -upgrade
[[ ${SKIP_INIT:-false} == false ]] && terraform init -upgrade
terraform apply -auto-approve
if [[ ${CI:-false} != true ]]; then
echo "PRESS ENTER TO CONTINUE..."
Expand Down Expand Up @@ -214,6 +241,7 @@ main() {
create-provider-version) run_create_provider_version "$@" ;;
build) run_build "$@" ;;
docker) run_docker "${TERRAFORM_VERSION:?}" "$@" ;;
dev) run_dev "$@" ;;
examples) run_examples "$@" ;;
test) run_test "$@" ;;
test-integration) run_test_integration "$@" ;;
Expand Down

0 comments on commit 922a242

Please sign in to comment.