diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index a7cf77bb..82fcc2e3 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -36,6 +36,7 @@ ENV ADMINIO_UI_PATH=/usr/local/share/adminio-ui # Copy and install pre-built AdminIO-UI COPY --from=adminio-ui /usr/share/nginx/html ${ADMINIO_UI_PATH} +RUN chmod -R 777 ${ADMINIO_UI_PATH} # Install Node.js ARG INSTALL_NODE="true" diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 71b6ddf4..c7f203b3 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,7 +17,7 @@ "hashicorp.terraform" ], "remoteUser": "vscode", - "postStartCommand": "make install_linux & minio server ${MINIO_VOLUMES} & adminio & npx angular-http-server -p ${ADMINIO_UI_PORT} --path ${ADMINIO_UI_PATH} &", + "postStartCommand": "go get github.com/go-task/task/v3/cmd/task && task install && minio server ${MINIO_VOLUMES} & adminio & npx angular-http-server -p ${ADMINIO_UI_PORT} --path ${ADMINIO_UI_PATH} &", "forwardPorts": [ 9000, 8080, diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 9053701c..c7c19fb7 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -42,13 +42,11 @@ jobs: run: go get -v -t -d ./... - name: Build the docker-compose stack run: docker-compose -f test-compose.yml up -d - - name: Test - env: - TF_ACC: 0 - MINIO_ENDPOINT: localhost:9000 - MINIO_ACCESS_KEY: minio - MINIO_SECRET_KEY: minio123 - MINIO_ENABLE_HTTPS: false - run: go test -count=1 -v -cover ./... + - name: Install Taskfile + uses: Arduino/actions/setup-taskfile@master + with: + version: '3.x' + - name: Run test task + run: task test - name: Remove containers run: docker rm -f minio diff --git a/.gitpod.yml b/.gitpod.yml index ed6617d7..e0ff9a4c 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -3,8 +3,17 @@ tasks: name: MinIO Server - command: adminio name: AdminIO Server - - command: npx angular-http-server -p ${ADMINIO_UI_PORT} --path ${ADMINIO_UI_PATH} + - command: | + sed -i 's/apiMultiBackend = true/apiMultiBackend = false/' ${ADMINIO_UI_PATH}/env.js && + sed -i 's/apiBaseUrl = "http:\/\/localhost:8080"/apiBaseUrl = `https:\/\/8080${location.hostname.substr(4)}`/' ${ADMINIO_UI_PATH}/env.js && + npx angular-http-server -p ${ADMINIO_UI_PORT} --path ${ADMINIO_UI_PATH} name: AdminIO-UI Server - - init: make install_linux + - init: | + cd $(mktemp -d) && + go mod init task && + go get github.com/go-task/task/v3/cmd/task && + cd - && + task install + name: Terminal image: file: .devcontainer/Dockerfile diff --git a/Makefile b/Makefile deleted file mode 100644 index 53997b40..00000000 --- a/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -VERSION=1.0.0 - -GO := ${GOROOT}/bin/go -ifeq ($(GOROOT),) -GO = go -endif - -default: build - -build: build_cleanup build_mac build_linux - -build_cleanup: - rm -f ./terraform-provider-minio_* - -build_mac: build_cleanup - @echo "Building terraform-provider-minio_v${VERSION}_darwin_amd64..." - env GOOS=darwin GOARCH=amd64 $(GO) build -o terraform-provider-minio_v${VERSION}_darwin_amd64 . - @echo "Done!" - -build_linux: build_cleanup - @echo "Building terraform-provider-minio_v${VERSION}_linux_amd64..." - env GOOS=linux GOARCH=amd64 $(GO) build -o terraform-provider-minio_v${VERSION}_linux_amd64 . - @echo "Done!" - -install_mac: build_mac - mkdir -p ~/Library/Application\ Support/io.terraform/plugins/registry.terraform.io/aminueza/minio/${VERSION}/darwin_amd64 - @echo "Moving terraform-provider-minio_v${VERSION}_darwin_amd64 into ~/Library/Application\ Support/io.terraform/plugins/registry.terraform.io/aminueza/minio/${VERSION}/darwin_amd64..." - mv terraform-provider-minio_v${VERSION}_darwin_amd64 ~/Library/Application\ Support/io.terraform/plugins/registry.terraform.io/aminueza/minio/${VERSION}/darwin_amd64/terraform-provider-minio_v${VERSION} - @echo "Done!" - -install_linux: build_linux - mkdir -p ~/.local/share/terraform/plugins/registry.terraform.io/aminueza/minio/${VERSION}/linux_amd64 - @echo "Moving terraform-provider-minio_v${VERSION}_linux_amd64 into ~/.local/share/terraform/plugins/registry.terraform.io/aminueza/minio/${VERSION}/linux_amd64..." - mv terraform-provider-minio_v${VERSION}_linux_amd64 ~/.local/share/terraform/plugins/registry.terraform.io/aminueza/minio/${VERSION}/linux_amd64/terraform-provider-minio_v${VERSION} - @echo "Done!" - -test: - TF_ACC=0 MINIO_ENDPOINT=localhost:9000 \ - MINIO_ACCESS_KEY=minio MINIO_SECRET_KEY=minio123 \ - MINIO_ENABLE_HTTPS=false $(GO) test -count=1 -v -cover ./... - -.PHONY: default build build_cleanup build_mac build_linux install_mac install_linux test \ No newline at end of file diff --git a/README.md b/README.md index 68f3fe13..dcdca6c8 100644 --- a/README.md +++ b/README.md @@ -57,32 +57,16 @@ It just means that we can't guarantee backward compatibility. Prebuilt versions of this provider are available for MacOS and Linux on the [releases page](https://github.com/aminueza/terraform-provider-minio/releases/latest). -But if you need to build it yourself, just download this repository and follow the instructions: +But if you need to build it yourself, just download this repository, [install](https://taskfile.dev/#/installation) [Task](https://taskfile.dev/): -### MacOS - -To build and install this plugin on MacOS, run: - -``` -make install_mac -``` - -### Linux - -To build and install this plugin on Linux, run: - -``` -make install_linux +```sh +go get github.com/go-task/task/v3/cmd/task ``` -### Windows +And run the following command to build and install the plugin in the correct folder (resolved automatically based on the current Operating System): -For Windows we don't have a Makefile, but it should be as simple as: - -``` -go build -o terraform-provider-minio_v1.0.0 -mkdir "%APPDATA%\HashiCorp\Terraform\plugins\registry.terraform.io\aminueza\minio\1.0.0\windows_amd64" -move terraform-provider-minio_v1.0.0 %APPDATA%\HashiCorp\Terraform\plugins\registry.terraform.io\aminueza\minio\1.0.0\windows_amd64 +```sh +task install ``` ## Examples diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 00000000..8e77b706 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,56 @@ +# https://taskfile.dev + +version: '3' + +vars: + PLUGIN_VERSION: 1.2.0 + OUTPUT_FILENAME: terraform-provider-minio + +tasks: + default: + cmds: + - task --list + silent: true + + build: + desc: Build the plugin into current folder. + cmds: + - echo "Building {{.OUTPUT_FILENAME}}" + - go build -o "{{.OUTPUT_FILENAME}}" + - echo "Done!" + silent: true + + install: + desc: Build and install the plugin in the correct folder (resolved automatically based on current Operating System). + vars: + WINDOWS_OUTPUT_PATH: '{{.APPDATA}}\HashiCorp\Terraform\plugins\registry.terraform.io\aminueza\minio\{{.PLUGIN_VERSION}}\{{OS}}_{{ARCH}}\{{.OUTPUT_FILENAME}}' + DARWIN_OUTPUT_PATH: '{{.HOME}}/Library/Application\ Support/io.terraform/plugins/registry.terraform.io/aminueza/minio/{{.PLUGIN_VERSION}}/{{OS}}_{{ARCH}}/{{.OUTPUT_FILENAME}}' + UNIX_OUTPUT_PATH: '{{.HOME}}/.local/share/terraform/plugins/registry.terraform.io/aminueza/minio/{{.PLUGIN_VERSION}}/{{OS}}_{{ARCH}}/{{.OUTPUT_FILENAME}}' + cmds: + - | + {{if eq OS "windows"}} + echo "Building and installing plugin in {{.WINDOWS_OUTPUT_PATH}}" + go build -o "{{.WINDOWS_OUTPUT_PATH}}" + {{else}} + {{if eq OS "darwin"}} + echo "Building and installing plugin in {{.DARWIN_OUTPUT_PATH}}" + go build -o "{{.DARWIN_OUTPUT_PATH}}" + {{else}} + echo "Building and installing plugin in {{.UNIX_OUTPUT_PATH}}" + go build -o "{{.UNIX_OUTPUT_PATH}}" + {{end}} + {{end}} + echo "Done!" + silent: true + + test: + desc: Run the package tests. + env: + TF_ACC: 0 + MINIO_ENDPOINT: localhost:9000 + MINIO_ACCESS_KEY: minio + MINIO_SECRET_KEY: minio123 + MINIO_ENABLE_HTTPS: false + cmds: + - go test -v -cover ./minio + silent: true diff --git a/examples/bucket/main.tf b/examples/bucket/main.tf index 272b3f55..30c753ea 100755 --- a/examples/bucket/main.tf +++ b/examples/bucket/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { minio = { source = "aminueza/minio" - version = "~> 1.0.0" + version = ">= 1.0.0" } } required_version = ">= 0.13" diff --git a/examples/group/main.tf b/examples/group/main.tf index 272b3f55..30c753ea 100755 --- a/examples/group/main.tf +++ b/examples/group/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { minio = { source = "aminueza/minio" - version = "~> 1.0.0" + version = ">= 1.0.0" } } required_version = ">= 0.13" diff --git a/examples/policy/main.tf b/examples/policy/main.tf index 272b3f55..30c753ea 100755 --- a/examples/policy/main.tf +++ b/examples/policy/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { minio = { source = "aminueza/minio" - version = "~> 1.0.0" + version = ">= 1.0.0" } } required_version = ">= 0.13" diff --git a/examples/user/main.tf b/examples/user/main.tf index 272b3f55..30c753ea 100755 --- a/examples/user/main.tf +++ b/examples/user/main.tf @@ -2,7 +2,7 @@ terraform { required_providers { minio = { source = "aminueza/minio" - version = "~> 1.0.0" + version = ">= 1.0.0" } } required_version = ">= 0.13"