diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..1c8292d --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1,27 @@ +# Contributor Code of Conduct + +As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities. + +We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality. + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery +* Personal attacks +* Trolling or insulting/derogatory comments +* Public or private harassment +* Publishing other's private information, such as physical or electronic addresses, without explicit permission +* Submitting contributions or comments that you know to violate the intellectual property or privacy rights of others +* Other unethical or unprofessional conduct + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. +By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team. + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting a project maintainer. Complaints will result in a response and be reviewed and investigated in a way that is deemed necessary and appropriate to the circumstances. Maintainers are obligated to maintain confidentiality with regard to the reporter of an incident. + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.3.0, available at [http://contributor-covenant.org/version/1/3/0/][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/3/0/ \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..98d7f5e --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: gomod + directory: / + schedule: + interval: "daily" diff --git a/.github/jfrog-logo-2022.svg b/.github/jfrog-logo-2022.svg new file mode 100644 index 0000000..ff99033 --- /dev/null +++ b/.github/jfrog-logo-2022.svg @@ -0,0 +1,3 @@ + + + diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..65cf221 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,21 @@ +changelog: + exclude: + labels: + - ignore-for-release + categories: + - title: Breaking Changes 🛠 + labels: + - breaking-change + - title: Improvements/Enhancements 🎉 + labels: + - enhancement + - new-feature + - title: Bug Fixes 🛠 + labels: + - bug + - title: 👒 Dependencies + labels: + - dependencies + - title: Other Changes 📚 + labels: + - "*" \ No newline at end of file diff --git a/.github/workflows/acceptance-tests.yml b/.github/workflows/acceptance-tests.yml new file mode 100644 index 0000000..2239408 --- /dev/null +++ b/.github/workflows/acceptance-tests.yml @@ -0,0 +1,210 @@ +on: + pull_request: + branches: + - main + types: [opened,synchronize] + paths: + - '**.go' + workflow_dispatch: + +name: Terraform & OpenTofu Acceptance Tests + +jobs: + acceptance-tests-matrix: + name: ${{ matrix.cli }} + runs-on: ubuntu-latest + continue-on-error: false + environment: development + strategy: + fail-fast: true + matrix: + cli: [terraform, tofu] + outputs: + tf_version: ${{ steps.get_terraform_cli_version.outputs.version }} + tofu_version: ${{ steps.get_opentofu_cli_version.outputs.version }} + artifactory_version: ${{ steps.run_artifactory_container.outputs.version }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Unshallow + run: git fetch --prune --unshallow + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.21 + - name: Install Helm + uses: azure/setup-helm@v4.2.0 + - name: Install Terraform CLI + uses: hashicorp/setup-terraform@v3 + if: ${{ matrix.cli == 'terraform' }} + - name: Get Terraform CLI version + id: get_terraform_cli_version + if: ${{ matrix.cli == 'terraform' }} + run: | + TF_VERSION=$(terraform -v -json | jq -r .terraform_version) + echo $TF_VERSION + echo "version=$TF_VERSION" >> "$GITHUB_OUTPUT" + - name: Install OpenTofu CLI + uses: opentofu/setup-opentofu@v1 + if: ${{ matrix.cli == 'tofu' }} + with: + tofu_wrapper: false + - name: Get OpenTofu CLI version + id: get_opentofu_cli_version + if: ${{ matrix.cli == 'tofu' }} + run: | + echo "TF_ACC_TERRAFORM_PATH=$(which tofu)" >> "$GITHUB_ENV" + echo "TF_ACC_PROVIDER_NAMESPACE=hashicorp" >> "$GITHUB_ENV" + echo "TF_ACC_PROVIDER_HOST=registry.opentofu.org" >> "$GITHUB_ENV" + TOFU_VERSION=$(tofu -v -json | jq -r .terraform_version) + echo $TOFU_VERSION + echo "version=$TOFU_VERSION" >> "$GITHUB_OUTPUT" + - name: Install GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + install-only: true + - name: Create Artifactory data directories and copy data + env: + ARTIFACTORY_LICENSE: ${{ secrets.ARTIFACTORY_LICENSE }} + run: | + mkdir -p ${{ runner.temp }}/artifactory/extra_conf + mkdir -p ${{ runner.temp }}/artifactory/var/etc + echo $ARTIFACTORY_LICENSE > ${{ runner.temp }}/artifactory/extra_conf/artifactory.lic + cp ${{ github.workspace }}/scripts/system.yaml ${{ runner.temp }}/artifactory/var/etc/system.yaml + sudo chown -R 1030:1030 ${{ runner.temp }}/artifactory/var + - name: Run Artifactory container + id: run_artifactory_container + run: | + echo "Get latest Artifactory image tag" + helm repo add artifactory https://charts.jfrog.io + helm repo update + ARTIFACTORY_VERSION=$(helm search repo | grep "artifactory " | awk '{$1=$1};1' | cut -f3 -d " ") + echo "version=$ARTIFACTORY_VERSION" >> "$GITHUB_OUTPUT" + echo "Start up Artifactory container" + docker run -i --name artifactory -d --rm \ + -v ${{ runner.temp }}/artifactory/extra_conf:/artifactory_extra_conf \ + -v ${{ runner.temp }}/artifactory/var:/var/opt/jfrog/artifactory \ + -p 8081:8081 -p 8082:8082 \ + releases-docker.jfrog.io/jfrog/artifactory-pro:${ARTIFACTORY_VERSION} + echo "Set localhost to a container IP address, since we run docker inside of docker" + export LOCALHOST=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.Gateway}}{{end}}' artifactory) + export JFROG_URL="http://${LOCALHOST}:8082" + echo "JFROG_URL=$JFROG_URL" >> "$GITHUB_ENV" + echo "Waiting for Artifactory services to start at ${JFROG_URL}" + until $(curl -sf -o /dev/null -m 5 ${JFROG_URL}/artifactory/api/system/ping/); do + printf '.' + sleep 5 + done + echo "Waiting for Artifactory UI to start" + until $(curl -sf -o /dev/null -m 5 ${JFROG_URL}/ui/login/); do + printf '.' + sleep 5 + done + export COOKIES=$(curl -s -c - "${JFROG_URL}/ui/api/v1/ui/auth/login?_spring_security_remember_me=false" \ + --header "accept: application/json, text/plain, */*" \ + --header "content-type: application/json;charset=UTF-8" \ + --header "x-requested-with: XMLHttpRequest" \ + -d '{"user":"admin","password":"'"${{ secrets.ARTIFACTORY_PASSWORD }}"'","type":"login"}' | grep FALSE) + export REFRESHTOKEN=$(echo $COOKIES | grep REFRESHTOKEN | awk '{print $7}') + export ACCESSTOKEN=$(echo $COOKIES | grep ACCESSTOKEN | awk '{print $14}') + export JFROG_ACCESS_TOKEN=$(curl -s -g --request GET "${JFROG_URL}/ui/api/v1/system/security/token?services[]=all" \ + --header "accept: application/json, text/plain, */*" \ + --header "x-requested-with: XMLHttpRequest" \ + --header "cookie: ACCESSTOKEN=${ACCESSTOKEN}; REFRESHTOKEN=${REFRESHTOKEN}") + echo "::add-mask::$JFROG_ACCESS_TOKEN" + echo "JFROG_ACCESS_TOKEN=$JFROG_ACCESS_TOKEN" >> "$GITHUB_ENV" + - name: Download license file + env: + JFROG_LICENSE_BUCKET_URL: ${{ secrets.JFROG_LICENSE_BUCKET_URL }} + run: | + curl -s -o ${{ runner.temp }}/encrypted_license.json $JFROG_LICENSE_BUCKET_URL + echo "JFROG_LICENSE_BUCKET_FILE=${{ runner.temp }}/encrypted_license.json" >> "$GITHUB_ENV" + - name: Execute acceptance tests + env: + JFROG_LICENSE_BUCKET_URL: ${{ secrets.JFROG_LICENSE_BUCKET_URL }} + JFROG_LICENSE_BUCKET_KEY: ${{ secrets.JFROG_LICENSE_BUCKET_KEY }} + run: make acceptance + - name: Install provider + run: | + export PROVIDER_VERSION=$(git describe --tags --abbrev=0 | sed -n 's/v\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1.\2.\3/p') + cat sample.tf | sed -e "s/version =.*/version = \"${PROVIDER_VERSION}\"/g" > sample.tf.tmp + cp sample.tf.tmp sample.tf && rm sample.tf.tmp + TERRAFORM_CLI=${{ matrix.cli }} make install + - name: Clean up Docker container + if: always() && ${{ steps.run_artifactory_container.outcome == 'success' }} + run: docker stop artifactory + - name: Send workflow status to Slack + uses: slackapi/slack-github-action@v1.26.0 + if: always() + with: + payload: | + { + "text": "${{ github.workflow }} https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ github.job }} ${{ matrix.cli }} GitHub Action result: ${{ job.status == 'success' && ':white_check_mark:' || ':x:' }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "${{ github.workflow }} : ${{ job.status == 'success' && ':white_check_mark:' || ':x:' }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}" + } + } + ] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_PR_WEBHOOK }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + + update-changelog: + runs-on: ubuntu-latest + needs: acceptance-tests-matrix + if: ${{ github.event_name == 'pull_request' }} && ${{ needs.acceptance-tests-matrix.result == 'success' }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref }} + - name: Update CHANGELOG and push commit + env: + ARTIFACTORY_VERSION: ${{ needs.acceptance-tests-matrix.outputs.artifactory_version }} + TERRAFORM_VERSION: ${{ needs.acceptance-tests-matrix.outputs.tf_version }} + OPENTOFU_VERSION: ${{ needs.acceptance-tests-matrix.outputs.tofu_version }} + run: | + echo "Adding Artifactory version to CHANGELOG.md" + sed -i -E "0,/(##\s.+\..+\..+\s\(.+\)).*/ s/(##\s.+\..+\..+\s\(.+\)).*/\1. Tested on Artifactory $ARTIFACTORY_VERSION with Terraform $TERRAFORM_VERSION and OpenTofu $OPENTOFU_VERSION/" CHANGELOG.md + head -10 CHANGELOG.md + git add CHANGELOG.md + export REGEX="Changes to be committed*" + export GIT_STATUS=$(git status) + if [[ ${GIT_STATUS} =~ ${REGEX} ]]; then + echo "Commiting changes" + git config --global user.name 'JFrog CI' + git config --global user.email 'jfrog-solutions-ci+1@jfrog.com' + git config --get user.name + git config --get user.email + git commit --author="JFrog CI " -m "JFrog Pipelines - Add Artifactory version to CHANGELOG.md" + git push + else + echo "There is nothing to commit: Artifactory version hadn't changed." + fi + - name: Send workflow status to Slack + uses: slackapi/slack-github-action@v1.26.0 + if: success() + with: + payload: | + { + "text": "Terraform Provider Platform. A new PR was submitted by ${{ github.event.pull_request.user.login }} - ${{ github.event.pull_request.html_url }}, branch ${{ github.event.pull_request.base.ref }}. Changes tested successfully. <@U01H1SLSPA8> or <@UNDRUL1EU> please, review and merge.", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": ". A new PR was submitted by *${{ github.event.pull_request.user.login }}* - <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>, branch *${{ github.event.pull_request.base.ref }}*. Changes tested successfully. <@U01H1SLSPA8> or <@UNDRUL1EU> please, review and merge." + } + } + ] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_PR_WEBHOOK }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 0000000..e5867be --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,19 @@ +name: "CHANGELOG check" +on: + pull_request: + types: [opened, synchronize, reopened, labeled, unlabeled] + +jobs: + build: + name: Check Actions + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Changelog check + uses: Zomzog/changelog-checker@v1.2.0 + with: + fileName: CHANGELOG.md + noChangelogLabel: "no changelog" + checkNotification: Detailed + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml new file mode 100644 index 0000000..6e6c87d --- /dev/null +++ b/.github/workflows/cla.yml @@ -0,0 +1,35 @@ +name: "CLA Assistant" +on: + # issue_comment triggers this action on each comment on issues and pull requests + issue_comment: + types: [created] + pull_request_target: + types: [opened,synchronize] + +jobs: + CLAssistant: + runs-on: ubuntu-latest + steps: + - uses: actions-ecosystem/action-regex-match@v2 + id: sign-or-recheck + with: + text: ${{ github.event.comment.body }} + regex: '\s*(I have read the CLA Document and I hereby sign the CLA)|(recheckcla)\s*' + + - name: "CLA Assistant" + if: ${{ steps.sign-or-recheck.outputs.match != '' || github.event_name == 'pull_request_target' }} + # Alpha Release + uses: cla-assistant/github-action@v2.1.1-beta + env: + # Generated and maintained by github + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # JFrog organization secret + PERSONAL_ACCESS_TOKEN : ${{ secrets.CLA_SIGN_TOKEN }} + with: + path-to-signatures: 'signed_clas.json' + path-to-document: 'https://jfrog.com/cla/' + remote-organization-name: 'jfrog' + remote-repository-name: 'jfrog-signed-clas' + # branch should not be protected + branch: 'master' + allowlist: bot* \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..67347a6 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 (paultyng/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 + if: | + (startsWith(github.ref, 'refs/tags/') && github.event.base_ref == 'refs/heads/main') + steps: + - + name: Checkout + uses: actions/checkout@v4 + - + name: Unshallow + run: git fetch --prune --unshallow + - + name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.21 + - + name: Import GPG key + id: import_gpg + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + version: ${{ github.event.inputs.tag }} + args: release --clean + env: + GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/slack-notify-issues.yml b/.github/workflows/slack-notify-issues.yml new file mode 100644 index 0000000..6f1bd2e --- /dev/null +++ b/.github/workflows/slack-notify-issues.yml @@ -0,0 +1,20 @@ +on: + issues: + types: [opened, reopened, deleted, closed] +name: Slack Issue Notification +jobs: + slackNotification: + name: Slack Notification Issue + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Slack Notification Issue + uses: rtCamp/action-slack-notify@master + env: + SLACK_CHANNEL: partnereng-issues + SLACK_COLOR: '#00A86B' + SLACK_ICON: https://pbs.twimg.com/profile_images/978188446178082817/86ulJdF0.jpg + SLACK_TITLE: "[${{ github.event.issue.state}}] ${{ github.event.issue.title }} on ${{ github.repository }} :rocket:" + SLACK_MESSAGE: 'Link: ${{ github.event.issue.html_url }}' + SLACK_USERNAME: PartnerEngineers + SLACK_WEBHOOK: ${{ secrets.SLACK_ISSUE_WEBHOOK }} diff --git a/.github/workflows/slack-notify-pr.yml b/.github/workflows/slack-notify-pr.yml new file mode 100644 index 0000000..b405506 --- /dev/null +++ b/.github/workflows/slack-notify-pr.yml @@ -0,0 +1,22 @@ +on: + pull_request_target: + branches: + - main + types: [opened, reopened, closed] +name: Slack Pull Request Notification +jobs: + slackNotification: + name: Slack Notification PR + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Slack Notification PR + uses: rtCamp/action-slack-notify@master + env: + SLACK_CHANNEL: partnereng-pullrequest + SLACK_COLOR: '#00A86B' + SLACK_ICON: https://pbs.twimg.com/profile_images/978188446178082817/86ulJdF0.jpg + SLACK_TITLE: "[${{ github.event.pull_request.state}}] ${{ github.event.pull_request.title }} on ${{ github.repository }} :rocket:" + SLACK_MESSAGE: 'Merging from ${{ github.head_ref }} to ${{ github.base_ref }} by ${{ github.actor }}. Link: ${{ github.event.pull_request._links.html.href }}' + SLACK_USERNAME: PartnerEngineers + SLACK_WEBHOOK: ${{ secrets.SLACK_PR_WEBHOOK }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c8d3dbb --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +dist/ +vendor/ +.idea/ +.modules/ +.terraform* +terraform.d/ +terraform.tfstate +terraform.tfstate.backup +lib/ +*.lic +scripts/artifactory_license*.json +/resources/ +.DS_Store +*.crt +*.backup +coverage.txt +.scannerwork +*.code-workspace +scripts/artifactory/ +*.hcl \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..23234ef --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,62 @@ +version: 2 + +# 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 github.com/jfrog/terraform-provider-mission-control/pkg/mc.Version={{.Version}}' + 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 is 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: + use: github-native diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..1ec3d8e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +## 1.0.0 (July 3, 2024). Tested on Artifactory 7.84.16 with Terraform 1.9.0 and OpenTofu 1.7.2 + +FEATURES: + +* **New Resource:** `missioncontrol_license_bucket` PR: [#2](https://github.com/jfrog/terraform-provider-mission-control/pull/2) \ No newline at end of file diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..7d008d1 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,2 @@ +* @alexhung +* @danielmkn diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..0c5037c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,78 @@ +# JFrog welcomes community contribution! + +Before we can accept your contribution, process your GitHub pull requests, and thank you full-heartedly, we request that you will fill out and submit JFrog's Contributor License Agreement (CLA). + +[Click here](https://gist.github.com/jfrog-ecosystem/7d4fbeaac18edbd3cfc38831125acbb3) to view the JFrog CLA. + +Please comment in your pull request to mark your acceptance for now until CLA assistant is fixed. + +"I have read the CLA Document and I hereby sign the CLA" + +This should only take a minute to complete and is a one-time process. + +*Thanks for Your Contribution to the Community!* :-) + +## Pull Request Process ## + +- Fork this repository. +- Clone the forked repository to your local machine and perform the proposed changes. +- Test the changes in your own K8s environment and confirm everything works end to end. +- Update the CHANGELOG.md +- Submit a PR with the relevant information and check the applicable boxes and fill out the questions. + +## Acceptance Criteria ## + +- Pull requests must pass all automated checks +- CHANGELOG.md has relevant changes +- README.md has been updated if required +- One approval from JFrog reviewers + +Upon the success of the above the pull request will be mergable into master branch. Upon merge the source branch will be removed. + +Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent. The versioning scheme we use is SemVer. +You may merge the Pull Request in once you have the sign-off of one other developer. + +## Code of Conduct +### Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +### Our Standards + +Examples of behavior that contributes to creating a positive environment include: + ```` + Using welcoming and inclusive language + Being respectful of differing viewpoints and experiences + Gracefully accepting constructive criticism + Focusing on what is best for the company + Showing empathy towards other colleagues + ```` + +Examples of unacceptable behavior by participants include: + + ```` + The use of sexualized language or imagery and unwelcome sexual attention or advances + Trolling, insulting/derogatory comments, and personal or political attacks + Public or private harassment + Publishing others' private information, such as a physical or electronic address, without explicit permission + Other conduct which could reasonably be considered inappropriate in a professional setting + ```` +### Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project. Examples of representing a project include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at Slack #xray_splunk . All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at http://contributor-covenant.org/version/1/4 diff --git a/CONTRIBUTIONS.md b/CONTRIBUTIONS.md new file mode 100644 index 0000000..23cb1b2 --- /dev/null +++ b/CONTRIBUTIONS.md @@ -0,0 +1,94 @@ +# Contribution Guide + +## Contributors + +Pull requests, issues and comments are welcomed. For pull requests: + +* Add tests for new features and bug fixes +* Follow the existing style +* Separate unrelated changes into multiple pull requests + +See the existing issues for things to start contributing. + +For bigger changes, make sure you start a discussion first by creating an issue and explaining the intended change. + +JFrog requires contributors to sign a Contributor License Agreement, known as a CLA. This serves as a record stating that the contributor is entitled to contribute the code/documentation/translation to the project and is willing to have it used in distributions and derivative works (or is willing to transfer ownership). + +## Building + +Simply run `make install` - this will compile the provider and install it to `~/.terraform.d`. When running this, it will take the current tag and bump it 1 patch version. It does not actually create a new tag. If you wish to use the locally installed provider, make sure your TF script refers to the new version number. + +Requirements: +- [Terraform](https://www.terraform.io/downloads.html) 1.7+ +- [Go](https://golang.org/doc/install) 1.21+ (to build the provider plugin) + +## Debugging + +See [debugging wiki](https://github.com/jfrog/terraform-provider-artifactory/wiki/Debugging). + +## Testing + +First, you need a running instance of the JFrog Artifactory. + +You can ask for an instance to test against it as part of your PR. Alternatively, you can run the file [scripts/run-artifactory.sh](scripts/run-artifactory.sh). + +The script requires a valid license of a [supported type](https://github.com/jfrog/terraform-provider-artifactory#license-requirements), license should be saved in the file called `artifactory.lic` in the same directory as a script. + +With the script you can start one or two Artifactory instances using docker compose. + +The license is not supplied but is required for local development. Make sure the license saved as a multi line text file. + +Currently, acceptance tests **require an access key**. To generate an access key, please refer to the [official documentation](https://jfrog.com/help/r/jfrog-platform-administration-documentation/generate-admin-tokens) + +Then, you have to set some environment variables as this is how the acceptance tests pick up their config. + +```sh +ARTIFACTORY_URL=http://localhost:8082 +ARTIFACTORY_USERNAME=admin +ARTIFACTORY_ACCESS_TOKEN= +TF_ACC=true +``` + +`ARTIFACTORY_USERNAME` is not used in authentication, but used in several tests, related to replication functionality. It should be hardcoded to `admin`, because it's a default user created in the Artifactory instance from the start. + +A crucial env var to set is `TF_ACC=true` - you can literally set `TF_ACC` to anything you want, so long as it's set. The acceptance tests use terraform testing libraries that, if this flag isn't set, will skip all tests. + +You can then run the tests as + +```sh +$ go test -v -p 1 ./pkg/... +``` + +Or + +```sh +$ make acceptance +``` + +**DO NOT** remove the `-v` - terraform testing needs this. This will recursively run all tests, including acceptance tests. + +#### Setup Artifactory instances + +The [scripts/run-artifactory.sh](scripts/run-artifactory.sh) starts two Artifactory instances for testing using the file [scripts/docker-compose.yml](scripts/docker-compose.yml). + +`artifactory-1` is on the usual 8080/8081/8082 ports while `artifactory-2` is on 9080/9081/9082 + +You can also run one instance of artifactory using `./run-artifactory-container.sh` which doesn't use docker-compose. + +#### Enable acceptance tests + +Set the env var to the second Artifactory instance URL. This is the URL that will be accessible from `artifactory-1` container (not the URL from the Docker host): +```sh +$ export ARTIFACTORY_URL_2=http://artifactory-2:8081 +``` + +Run all the acceptance tests as usual +```sh +$ make acceptance +``` + +## Releasing + +Please create a pull request against the master branch. Each pull request will be reviewed by a member of the JFrog team. + +#### Thank you for contributing! diff --git a/GNUmakefile b/GNUmakefile new file mode 100644 index 0000000..c0c6654 --- /dev/null +++ b/GNUmakefile @@ -0,0 +1,82 @@ +TEST?=./... +PRODUCT=mission-control +GO_ARCH=$(shell go env GOARCH) +TARGET_ARCH=$(shell go env GOOS)_${GO_ARCH} +GORELEASER_ARCH=${TARGET_ARCH} + +ifeq ($(GO_ARCH), amd64) +GORELEASER_ARCH=${TARGET_ARCH}_$(shell go env GOAMD64) +endif + +PKG_NAME=pkg/${PRODUCT} +# if this path ever changes, you need to also update the 'ldflags' value in .goreleaser.yml +PKG_VERSION_PATH=github.com/jfrog/terraform-provider-${PRODUCT}/${PKG_NAME} +VERSION := $(shell git tag --sort=-creatordate | head -1 | sed -n 's/v\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1.\2.\3/p') +NEXT_VERSION?=$(shell echo ${VERSION}| awk -F '.' '{print $$1 "." $$2 "." $$3 +1 }') + +TERRAFORM_CLI?=terraform + +REGISTRY_HOST=registry.terraform.io + +ifeq ($(TERRAFORM_CLI), tofu) +REGISTRY_HOST=registry.opentofu.org +endif + +BUILD_PATH=terraform.d/plugins/${REGISTRY_HOST}/jfrog/${PRODUCT}/${NEXT_VERSION}/${TARGET_ARCH} + +SONAR_SCANNER_VERSION?=4.7.0.2747 +SONAR_SCANNER_HOME?=${HOME}/.sonar/sonar-scanner-${SONAR_SCANNER_VERSION}-macosx + +default: build + +install: clean build + rm -fR .terraform.d && \ + mkdir -p ${BUILD_PATH} && \ + mv -v dist/terraform-provider-${PRODUCT}_${GORELEASER_ARCH}/terraform-provider-${PRODUCT}_v${NEXT_VERSION}* ${BUILD_PATH} && \ + rm -f .terraform.lock.hcl && \ + sed -i.bak '0,/version = ".*"/s//version = "${NEXT_VERSION}"/' sample.tf && rm sample.tf.bak && \ + ${TERRAFORM_CLI} init + +clean: + rm -fR dist terraform.d/ .terraform terraform.tfstate* .terraform.lock.hcl + +release: + @git tag ${NEXT_VERSION} && git push --mirror + @echo "Pushed ${NEXT_VERSION}" + GOPROXY=https://proxy.golang.org GO111MODULE=on go get github.com/jfrog/terraform-provider-${PRODUCT}@v${NEXT_VERSION} + @echo "Updated pkg cache" + +update_pkg_cache: + GOPROXY=https://proxy.golang.org GO111MODULE=on go get github.com/jfrog/terraform-provider-${PRODUCT}@v${VERSION} + +build: fmt + GORELEASER_CURRENT_TAG=${NEXT_VERSION} goreleaser build --single-target --clean --snapshot + +test: + @echo "==> Starting unit tests" + go test $(TEST) -timeout=30s -parallel=4 + +attach: + dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient attach $$(pgrep terraform-provider-${PRODUCT}) + +acceptance: fmt + export TF_ACC=true && \ + go test -cover -coverprofile=coverage.txt -ldflags="-X '${PKG_VERSION_PATH}.Version=${NEXT_VERSION}-test'" -v -p 1 -parallel 20 -timeout 20m ./pkg/... + +# To generate coverage.txt run `make acceptance` first +coverage: + go tool cover -html=coverage.txt + +# SONAR_TOKEN (project token) must be set to run `make scan`. Check file sonar-project.properties for the configuration. +scan: + ${SONAR_SCANNER_HOME}/bin/sonar-scanner -Dsonar.projectVersion=${VERSION} -Dsonar.go.coverage.reportPaths=coverage.txt + +fmt: + @echo "==> Fixing source code with gofmt..." + @go fmt ./pkg/... + +doc: + rm -rfv docs/* + go generate + +.PHONY: build fmt diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8821a5f --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2020 JFrog Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e198fc4 --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ +[![Terraform & OpenTofu Acceptance Tests](https://github.com/jfrog/terraform-provider-platform/actions/workflows/acceptance-tests.yml/badge.svg)](https://github.com/jfrog/terraform-provider-platform/actions/workflows/acceptance-tests.yml) + +# Terraform Provider for JFrog Mission Control + +## Quick Start + +Create a new Terraform file with `missioncontrol` resource. Also see [sample.tf](./sample.tf): + +### HCL Example + +```terraform +# Required for Terraform 1.0 and later +terraform { + required_providers { + missioncontrol = { + source = "jfrog/mission-control" + version = "1.0.0" + } + } +} + +provider "missioncontrol" { + // supply JFROG_URL and JFROG_ACCESS_TOKEN as env vars +} +``` + +Initialize Terrform: +```sh +$ terraform init +``` + +Plan (or Apply): +```sh +$ terraform plan +``` + +Detailed documentation of the resource and attributes are on [Terraform Registry](https://registry.terraform.io/providers/jfrog/mission-control/latest/docs). + +## Versioning + +In general, this project follows [semver](https://semver.org/) as closely as we can for tagging releases of the package. We've adopted the following versioning policy: + +* We increment the **major version** with any incompatible change to functionality, including changes to the exported Go API surface or behavior of the API. +* We increment the **minor version** with any backwards-compatible changes to functionality. +* We increment the **patch version** with any backwards-compatible bug fixes. + +## Contributors + +See the [contribution guide](CONTRIBUTIONS.md). + +## License + +Copyright (c) 2024 JFrog. + +Apache 2.0 licensed, see [LICENSE][LICENSE] file. + +[LICENSE]: ./LICENSE diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..24eb734 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,120 @@ +--- +layout: "" +page_title: "JFrog Mission Control Provider" +description: |- + The JFrog Mission Control provider provides resources to interact with features from JFrog Mission Control. +--- + +# JFrog Mission Control Provider + +The [JFrog](https://jfrog.com/) Mission Control provider is used to interact with the features from [JFrog Mission Control REST API](https://jfrog.com/help/r/jfrog-rest-apis/mission-control-rest-apis). The provider needs to be configured with the proper credentials before it can be used. + +Links to documentation for specific resources can be found in the table of contents to the left. + +## Example Usage + +```terraform +terraform { + required_providers { + missioncontrol = { + source = "jfrog/mission-control" + version = "1.0.0" + } + } +} + +variable "jfrog_url" { + type = string + default = "http://localhost:8081" +} + +provider "missioncontrol" { + url = "${var.jfrog_url}" + // supply JFROG_ACCESS_TOKEN as env var +} + +resource "missioncontrol_license_bucket" "my-license-bucket" { + name = "my-license-bucket" + url = "https://buckets.jfrog.io/download/...63aeb8c664" + key = "my-license-bucket-key" +} +``` + +## Authentication + +The JFrog Mission Control provider supports for the following types of authentication: +* Scoped token +* Terraform Cloud OIDC provider + +### Scoped Token + +JFrog scoped tokens may be used via the HTTP Authorization header by providing the `access_token` field to the provider block. Getting this value from the environment is supported with the `JFROG_ACCESS_TOKEN` environment variable. + +Usage: +```terraform +provider "missioncontrol" { + url = "my.jfrog.io" + access_token = "abc...xy" +} +``` + +### Terraform Cloud OIDC Provider + +If you are using this provider on Terraform Cloud and wish to use dynamic credentials instead of static access token for authentication with JFrog platform, you can leverage Terraform as the OIDC provider. + +To setup dynamic credentials, follow these steps: +1. Configure Terraform Cloud as a generic OIDC provider +2. Set environment variable in your Terraform Workspace +3. Setup Terraform Cloud in your configuration + +During the provider start up, if it finds env var `TFC_WORKLOAD_IDENTITY_TOKEN` it will use this token with your JFrog instance to exchange for a short-live access token. If that is successful, the provider will the access token for all subsequent API requests with the JFrog instance. + +#### Configure Terraform Cloud as generic OIDC provider + +Follow [confgure an OIDC integration](https://jfrog.com/help/r/jfrog-platform-administration-documentation/configure-an-oidc-integration). Enter a name for the provider, e.g. `terraform-cloud`. Use `https://app.terraform.io` for "Provider URL". Choose your own value for "Audience", e.g. `jfrog-terraform-cloud`. + +Then [configure an identity mapping](https://jfrog.com/help/r/jfrog-platform-administration-documentation/configure-identity-mappings) with an empty "Claims JSON" (`{}`), and select the "Token scope", "User", and "Service" as desired. + +#### Set environment variable in your Terraform Workspace + +In your workspace, add an environment variable `TFC_WORKLOAD_IDENTITY_AUDIENCE` with audience value (e.g. `jfrog-terraform-cloud`) from JFrog OIDC integration above. See [Manually Generating Workload Identity Tokens](https://developer.hashicorp.com/terraform/cloud-docs/workspaces/dynamic-provider-credentials/manual-generation) for more details. + +When a run starts on Terraform Cloud, it will create a workload identity token with the specified audience and assigns it to the environment variable `TFC_WORKLOAD_IDENTITY_TOKEN` for the provider to consume. + +#### Setup Terraform Cloud in your configuration + +Add `cloud` block to `terraform` block, and add `oidc_provider_name` attribute (from JFrog OIDC integration) to provider block: + +```terraform +terraform { + cloud { + organization = "my-org" + workspaces { + name = "my-workspace" + } + } + + required_providers { + missioncontrol = { + source = "jfrog/mission-control" + version = "1.0.0" + } + } +} + +provider "missioncontrol" { + url = "https://myinstance.jfrog.io" + oidc_provider_name = "terraform-cloud" +} +``` + +**Note:** Ensure `access_token` attribute is not set + + +## Schema + +### Optional + +- `access_token` (String, Sensitive) This is a access token that can be given to you by your admin under `Platform Configuration -> User Management -> Access Tokens`. This can also be sourced from the `JFROG_ACCESS_TOKEN` environment variable. +- `oidc_provider_name` (String) OIDC provider name. See [Configure an OIDC Integration](https://jfrog.com/help/r/jfrog-platform-administration-documentation/configure-an-oidc-integration) for more details. +- `url` (String) JFrog Platform URL. This can also be sourced from the `JFROG_URL` environment variable. diff --git a/docs/resources/license_bucket.md b/docs/resources/license_bucket.md new file mode 100644 index 0000000..30fcd7a --- /dev/null +++ b/docs/resources/license_bucket.md @@ -0,0 +1,47 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "missioncontrol_license_bucket Resource - missioncontrol" +subcategory: "" +description: |- + Provides a JFrog license bucket https://jfrog.com/help/r/jfrog-platform-administration-documentation/manage-license-buckets resource to manage license buckets. +--- + +# missioncontrol_license_bucket (Resource) + +Provides a JFrog [license bucket](https://jfrog.com/help/r/jfrog-platform-administration-documentation/manage-license-buckets) resource to manage license buckets. + +## Example Usage + +```terraform +resource "missioncontrol_license_bucket" "my-license-bucket" { + name = "my-license-bucket" + url = "https://buckets.jfrog.io/download/...63aeb8c664" + key = "my-license-bucket-key" +} +``` + + +## Schema + +### Required + +- `key` (String) License bucket key. +- `name` (String) Name of the license bucket + +### Optional + +- `file` (String) File path to the license bucket. Can't be set together with `url`. +- `url` (String) Signed URL of the license bucket. Can't be set together with `file`. + +### Read-Only + +- `id` (String) The identifier of this license bucket. +- `issued_date` (String) The issue date for this license bucket. +- `license_type` (String) The license type of this license bucket. +- `product_id` (Number) +- `product_name` (String) +- `quantity` (Number) The total number of licenses in this bucket. +- `signature` (String) +- `subject` (String) The customer name of this license bucket. +- `used` (Number) The number of used licenses in this bucket. +- `valid_date` (String) The expiry date for this license bucket. diff --git a/examples/example.tf b/examples/example.tf new file mode 100644 index 0000000..f27e268 --- /dev/null +++ b/examples/example.tf @@ -0,0 +1,24 @@ +terraform { + required_providers { + missioncontrol = { + source = "jfrog/mission-control" + version = "1.0.0" + } + } +} + +variable "jfrog_url" { + type = string + default = "http://localhost:8081" +} + +provider "missioncontrol" { + url = "${var.jfrog_url}" + // supply JFROG_ACCESS_TOKEN as env var +} + +resource "missioncontrol_license_bucket" "my-license-bucket" { + name = "my-license-bucket" + url = "https://buckets.jfrog.io/download/...63aeb8c664" + key = "my-license-bucket-key" +} \ No newline at end of file diff --git a/examples/provider/provider.tf b/examples/provider/provider.tf new file mode 100644 index 0000000..48d4195 --- /dev/null +++ b/examples/provider/provider.tf @@ -0,0 +1,4 @@ +provider "missioncontrol" { + url = "${var.jfrog_url}" + access_token = "${var.jfrog_access_token}" +} \ No newline at end of file diff --git a/examples/resources/missioncontrol_license_bucket/resource.tf b/examples/resources/missioncontrol_license_bucket/resource.tf new file mode 100644 index 0000000..7c9ac6c --- /dev/null +++ b/examples/resources/missioncontrol_license_bucket/resource.tf @@ -0,0 +1,5 @@ +resource "missioncontrol_license_bucket" "my-license-bucket" { + name = "my-license-bucket" + url = "https://buckets.jfrog.io/download/...63aeb8c664" + key = "my-license-bucket-key" +} \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..7ec9b91 --- /dev/null +++ b/go.mod @@ -0,0 +1,89 @@ +module github.com/jfrog/terraform-provider-mission-control + +go 1.21.5 + +require ( + github.com/go-resty/resty/v2 v2.13.1 + github.com/hashicorp/terraform-plugin-docs v0.19.4 + github.com/hashicorp/terraform-plugin-framework v1.9.0 + github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 + github.com/hashicorp/terraform-plugin-go v0.23.0 + github.com/hashicorp/terraform-plugin-testing v1.8.0 + github.com/jfrog/terraform-provider-shared v1.25.5 + github.com/samber/lo v1.44.0 +) + +require ( + github.com/BurntSushi/toml v1.2.1 // indirect + github.com/Kunde21/markdownfmt/v3 v3.1.0 // indirect + github.com/Masterminds/goutils v1.1.1 // indirect + github.com/Masterminds/semver/v3 v3.2.0 // indirect + github.com/Masterminds/sprig/v3 v3.2.3 // indirect + github.com/ProtonMail/go-crypto v1.1.0-alpha.2 // indirect + github.com/agext/levenshtein v1.2.2 // indirect + github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect + github.com/armon/go-radix v1.0.0 // indirect + github.com/bgentry/speakeasy v0.1.0 // indirect + github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect + github.com/cloudflare/circl v1.3.7 // indirect + github.com/fatih/color v1.16.0 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75 // indirect + github.com/hashicorp/cli v1.1.6 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-checkpoint v0.5.0 // indirect + github.com/hashicorp/go-cleanhttp v0.5.2 // indirect + github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect + github.com/hashicorp/go-hclog v1.6.3 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/hashicorp/go-plugin v1.6.0 // indirect + github.com/hashicorp/go-uuid v1.0.3 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect + github.com/hashicorp/hc-install v0.7.0 // indirect + github.com/hashicorp/hcl/v2 v2.20.1 // indirect + github.com/hashicorp/logutils v1.0.0 // indirect + github.com/hashicorp/terraform-exec v0.21.0 // indirect + github.com/hashicorp/terraform-json v0.22.1 // indirect + github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect + github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 // indirect + github.com/hashicorp/terraform-registry-address v0.2.3 // indirect + github.com/hashicorp/terraform-svchost v0.1.1 // indirect + github.com/hashicorp/yamux v0.1.1 // indirect + github.com/huandu/xstrings v1.3.3 // indirect + github.com/imdario/mergo v0.3.15 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-runewidth v0.0.9 // indirect + github.com/mitchellh/copystructure v1.2.0 // indirect + github.com/mitchellh/go-testing-interface v1.14.1 // indirect + github.com/mitchellh/go-wordwrap v1.0.0 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/mitchellh/reflectwalk v1.0.2 // indirect + github.com/oklog/run v1.0.0 // indirect + github.com/posener/complete v1.2.3 // indirect + github.com/shopspring/decimal v1.3.1 // indirect + github.com/spf13/cast v1.5.0 // indirect + github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect + github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect + github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect + github.com/yuin/goldmark v1.7.1 // indirect + github.com/yuin/goldmark-meta v1.1.0 // indirect + github.com/zclconf/go-cty v1.14.4 // indirect + go.abhg.dev/goldmark/frontmatter v0.2.0 // indirect + golang.org/x/crypto v0.23.0 // indirect + golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/net v0.25.0 // indirect + golang.org/x/sync v0.7.0 // indirect + golang.org/x/sys v0.20.0 // indirect + golang.org/x/text v0.16.0 // indirect + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect + google.golang.org/appengine v1.6.8 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect + google.golang.org/grpc v1.63.2 // indirect + google.golang.org/protobuf v1.34.0 // indirect + gopkg.in/yaml.v2 v2.3.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..d4c5190 --- /dev/null +++ b/go.sum @@ -0,0 +1,311 @@ +dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= +dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= +github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/Kunde21/markdownfmt/v3 v3.1.0 h1:KiZu9LKs+wFFBQKhrZJrFZwtLnCCWJahL+S+E/3VnM0= +github.com/Kunde21/markdownfmt/v3 v3.1.0/go.mod h1:tPXN1RTyOzJwhfHoon9wUr4HGYmWgVxSQN6VBJDkrVc= +github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= +github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/semver/v3 v3.2.0 h1:3MEsd0SM6jqZojhjLWWeBY+Kcjy9i6MQAeY7YgDP83g= +github.com/Masterminds/semver/v3 v3.2.0/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= +github.com/Masterminds/sprig/v3 v3.2.3 h1:eL2fZNezLomi0uOLqjQoN6BfsDD+fyLtgbJMAj9n6YA= +github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBaRMhvYXJNkGuM= +github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= +github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= +github.com/ProtonMail/go-crypto v1.1.0-alpha.2 h1:bkyFVUP+ROOARdgCiJzNQo2V2kiB97LyUpzH9P6Hrlg= +github.com/ProtonMail/go-crypto v1.1.0-alpha.2/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= +github.com/agext/levenshtein v1.2.2 h1:0S/Yg6LYmFJ5stwQeRp6EeOcCbj7xiqQSdNelsXvaqE= +github.com/agext/levenshtein v1.2.2/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558= +github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= +github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY= +github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4= +github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= +github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I= +github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc= +github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= +github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= +github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= +github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= +github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= +github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= +github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= +github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= +github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= +github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= +github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= +github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= +github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= +github.com/go-resty/resty/v2 v2.13.1 h1:x+LHXBI2nMB1vqndymf26quycC4aggYJ7DECYbiz03g= +github.com/go-resty/resty/v2 v2.13.1/go.mod h1:GznXlLxkq6Nh4sU59rPmUw3VtgpO3aS96ORAI6Q7d+0= +github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= +github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75 h1:f0n1xnMSmBLzVfsMMvriDyA75NB/oBgILX2GcHXIQzY= +github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75/go.mod h1:g2644b03hfBX9Ov0ZBDgXXens4rxSxmqFBbhvKv2yVA= +github.com/hashicorp/cli v1.1.6 h1:CMOV+/LJfL1tXCOKrgAX0uRKnzjj/mpmqNXloRSy2K8= +github.com/hashicorp/cli v1.1.6/go.mod h1:MPon5QYlgjjo0BSoAiN0ESeT5fRzDjVRp+uioJ0piz4= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= +github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= +github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= +github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= +github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= +github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= +github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= +github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= +github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= +github.com/hashicorp/go-plugin v1.6.0 h1:wgd4KxHJTVGGqWBq4QPB1i5BZNEx9BR8+OFmHDmTk8A= +github.com/hashicorp/go-plugin v1.6.0/go.mod h1:lBS5MtSSBZk0SHc66KACcjjlU6WzEVP/8pwz68aMkCI= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= +github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/hc-install v0.7.0 h1:Uu9edVqjKQxxuD28mR5TikkKDd/p55S8vzPC1659aBk= +github.com/hashicorp/hc-install v0.7.0/go.mod h1:ELmmzZlGnEcqoUMKUuykHaPCIR1sYLYX+KSggWSKZuA= +github.com/hashicorp/hcl/v2 v2.20.1 h1:M6hgdyz7HYt1UN9e61j+qKJBqR3orTWbI1HKBJEdxtc= +github.com/hashicorp/hcl/v2 v2.20.1/go.mod h1:TZDqQ4kNKCbh1iJp99FdPiUaVDDUPivbqxZulxDYqL4= +github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/terraform-exec v0.21.0 h1:uNkLAe95ey5Uux6KJdua6+cv8asgILFVWkd/RG0D2XQ= +github.com/hashicorp/terraform-exec v0.21.0/go.mod h1:1PPeMYou+KDUSSeRE9szMZ/oHf4fYUmB923Wzbq1ICg= +github.com/hashicorp/terraform-json v0.22.1 h1:xft84GZR0QzjPVWs4lRUwvTcPnegqlyS7orfb5Ltvec= +github.com/hashicorp/terraform-json v0.22.1/go.mod h1:JbWSQCLFSXFFhg42T7l9iJwdGXBYV8fmmD6o/ML4p3A= +github.com/hashicorp/terraform-plugin-docs v0.19.4 h1:G3Bgo7J22OMtegIgn8Cd/CaSeyEljqjH3G39w28JK4c= +github.com/hashicorp/terraform-plugin-docs v0.19.4/go.mod h1:4pLASsatTmRynVzsjEhbXZ6s7xBlUw/2Kt0zfrq8HxA= +github.com/hashicorp/terraform-plugin-framework v1.9.0 h1:caLcDoxiRucNi2hk8+j3kJwkKfvHznubyFsJMWfZqKU= +github.com/hashicorp/terraform-plugin-framework v1.9.0/go.mod h1:qBXLDn69kM97NNVi/MQ9qgd1uWWsVftGSnygYG1tImM= +github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 h1:HOjBuMbOEzl7snOdOoUfE2Jgeto6JOjLVQ39Ls2nksc= +github.com/hashicorp/terraform-plugin-framework-validators v0.12.0/go.mod h1:jfHGE/gzjxYz6XoUwi/aYiiKrJDeutQNUtGQXkaHklg= +github.com/hashicorp/terraform-plugin-go v0.23.0 h1:AALVuU1gD1kPb48aPQUjug9Ir/125t+AAurhqphJ2Co= +github.com/hashicorp/terraform-plugin-go v0.23.0/go.mod h1:1E3Cr9h2vMlahWMbsSEcNrOCxovCZhOOIXjFHbjc/lQ= +github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= +github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 h1:qHprzXy/As0rxedphECBEQAh3R4yp6pKksKHcqZx5G8= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0/go.mod h1:H+8tjs9TjV2w57QFVSMBQacf8k/E1XwLXGCARgViC6A= +github.com/hashicorp/terraform-plugin-testing v1.8.0 h1:wdYIgwDk4iO933gC4S8KbKdnMQShu6BXuZQPScmHvpk= +github.com/hashicorp/terraform-plugin-testing v1.8.0/go.mod h1:o2kOgf18ADUaZGhtOl0YCkfIxg01MAiMATT2EtIHlZk= +github.com/hashicorp/terraform-registry-address v0.2.3 h1:2TAiKJ1A3MAkZlH1YI/aTVcLZRu7JseiXNRHbOAyoTI= +github.com/hashicorp/terraform-registry-address v0.2.3/go.mod h1:lFHA76T8jfQteVfT7caREqguFrW3c4MFSPhZB7HHgUM= +github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S52uzrw4x0jKQ= +github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= +github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= +github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= +github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4= +github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= +github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= +github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= +github.com/jfrog/terraform-provider-shared v1.25.5 h1:+hal/9yDAIt2mZljDR8Ymie28yAHr8CAkfthwQ3O3bM= +github.com/jfrog/terraform-provider-shared v1.25.5/go.mod h1:QthwPRUALElMt2RTGqoeB/3Vztx626YPBzIAoqEp0w0= +github.com/jhump/protoreflect v1.15.1 h1:HUMERORf3I3ZdX05WaQ6MIpd/NJ434hTp5YiKgfCL6c= +github.com/jhump/protoreflect v1.15.1/go.mod h1:jD/2GMKKE6OqX8qTjhADU1e6DShO+gavG9e0Q693nKo= +github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= +github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= +github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= +github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= +github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= +github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= +github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= +github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo= +github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= +github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= +github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/samber/lo v1.44.0 h1:5il56KxRE+GHsm1IR+sZ/6J42NODigFiqCWpSc2dybA= +github.com/samber/lo v1.44.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= +github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= +github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= +github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= +github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= +github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= +github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= +github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= +github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= +github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= +github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= +github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= +github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= +github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yuin/goldmark v1.7.1 h1:3bajkSilaCbjdKVsKdZjZCLBNPL9pYzrCakKaf4U49U= +github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= +github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUeiOUc= +github.com/yuin/goldmark-meta v1.1.0/go.mod h1:U4spWENafuA7Zyg+Lj5RqK/MF+ovMYtBvXi1lBb2VP0= +github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8= +github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= +github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b h1:FosyBZYxY34Wul7O/MSKey3txpPYyCqVO5ZyceuQJEI= +github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= +go.abhg.dev/goldmark/frontmatter v0.2.0 h1:P8kPG0YkL12+aYk2yU3xHv4tcXzeVnN+gU0tJ5JnxRw= +go.abhg.dev/goldmark/frontmatter v0.2.0/go.mod h1:XqrEkZuM57djk7zrlRUB02x8I5J0px76YjkOzhB4YlU= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df h1:UA2aFVmmsIlefxMk29Dp2juaUSth8Pyn3Tq5Y5mJGME= +golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.34.0 h1:Qo/qEd2RZPCf2nKuorzksSknv0d3ERwp1vFG38gSmH4= +google.golang.org/protobuf v1.34.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go new file mode 100644 index 0000000..945df10 --- /dev/null +++ b/main.go @@ -0,0 +1,31 @@ +package main + +import ( + "context" + "flag" + "log" + + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/jfrog/terraform-provider-mission-control/pkg/missioncontrol" +) + +// Run the docs generation tool, check its repository for more information on how it works and how docs +// can be customized. +//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate --provider-name missioncontrol + +func main() { + var debug bool + + flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve") + flag.Parse() + + opts := providerserver.ServeOpts{ + Address: "registry.terraform.io/jfrog/mission-control", + Debug: debug, + } + + err := providerserver.Serve(context.Background(), missioncontrol.NewProvider(), opts) + if err != nil { + log.Fatal(err.Error()) + } +} diff --git a/pkg/missioncontrol/provider.go b/pkg/missioncontrol/provider.go new file mode 100644 index 0000000..34794b0 --- /dev/null +++ b/pkg/missioncontrol/provider.go @@ -0,0 +1,181 @@ +package missioncontrol + +import ( + "context" + "fmt" + + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/provider" + "github.com/hashicorp/terraform-plugin-framework/provider/schema" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/jfrog/terraform-provider-shared/client" + "github.com/jfrog/terraform-provider-shared/util" + validator_string "github.com/jfrog/terraform-provider-shared/validator/fw/string" +) + +var Version = "1.0.0" + +// needs to be exported so make file can update this +var productId = "terraform-provider-mission-control/" + Version + +var _ provider.Provider = (*MissionControlProvider)(nil) + +type MissionControlProvider struct { + Meta util.ProviderMetadata +} + +type missionControlProviderModel struct { + URL types.String `tfsdk:"url"` + AccessToken types.String `tfsdk:"access_token"` + OIDCProviderName types.String `tfsdk:"oidc_provider_name"` +} + +func NewProvider() func() provider.Provider { + return func() provider.Provider { + return &MissionControlProvider{} + } +} + +func (p *MissionControlProvider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) { + // Check environment variables, first available OS variable will be assigned to the var + url := util.CheckEnvVars([]string{"JFROG_URL"}, "") + accessToken := util.CheckEnvVars([]string{"JFROG_ACCESS_TOKEN"}, "") + + var config missionControlProviderModel + + // Read configuration data into model + resp.Diagnostics.Append(req.Config.Get(ctx, &config)...) + if resp.Diagnostics.HasError() { + return + } + + if config.URL.ValueString() != "" { + url = config.URL.ValueString() + } + + if url == "" { + resp.Diagnostics.AddError( + "Missing URL Configuration", + "While configuring the provider, the url was not found in the JFROG_URL environment variable or provider configuration block url attribute.", + ) + return + } + + platformClient, err := client.Build(url, productId) + if err != nil { + resp.Diagnostics.AddError( + "Error creating Resty client", + err.Error(), + ) + return + } + + oidcAccessToken, err := util.OIDCTokenExchange(ctx, platformClient, config.OIDCProviderName.ValueString()) + if err != nil { + resp.Diagnostics.AddError( + "Failed OIDC ID token exchange", + err.Error(), + ) + return + } + + // use token from OIDC provider, which should take precedence over + // environment variable data, if found. + if oidcAccessToken != "" { + accessToken = oidcAccessToken + } + + // use token from configuration, which should take precedence over + // environment variable data or OIDC provider, if found. + if config.AccessToken.ValueString() != "" { + accessToken = config.AccessToken.ValueString() + } + + if accessToken == "" { + resp.Diagnostics.AddWarning( + "Missing JFrog Access Token", + "Access Token was not found in the JFROG_ACCESS_TOKEN environment variable, provider configuration block access_token attribute, or Terraform Cloud TFC_WORKLOAD_IDENTITY_TOKEN environment variable. Mission Control functionality will be affected.", + ) + } + + _, err = client.AddAuth(platformClient, "", accessToken) + if err != nil { + resp.Diagnostics.AddError( + "Error adding Auth to Resty client", + err.Error(), + ) + return + } + + version, err := util.GetArtifactoryVersion(platformClient) + if err != nil { + resp.Diagnostics.AddError( + "Error getting Artifactory version", + err.Error(), + ) + return + } + + featureUsage := fmt.Sprintf("Terraform/%s", req.TerraformVersion) + go util.SendUsage(ctx, platformClient.R(), productId, featureUsage) + + meta := util.ProviderMetadata{ + Client: platformClient, + ArtifactoryVersion: version, + } + + p.Meta = meta + + resp.DataSourceData = meta + resp.ResourceData = meta +} + +func (p *MissionControlProvider) Metadata(ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse) { + resp.TypeName = "missioncontrol" + resp.Version = Version +} + +func (p *MissionControlProvider) DataSources(ctx context.Context) []func() datasource.DataSource { + return []func() datasource.DataSource{ + // NewDataSource, + } +} + +func (p *MissionControlProvider) Resources(ctx context.Context) []func() resource.Resource { + return []func() resource.Resource{ + NewLicenseBucketResource, + } +} + +func (p *MissionControlProvider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "url": schema.StringAttribute{ + Optional: true, + Validators: []validator.String{ + validator_string.IsURLHttpOrHttps(), + }, + MarkdownDescription: "JFrog Platform URL. This can also be sourced from the `JFROG_URL` environment variable.", + }, + "access_token": schema.StringAttribute{ + Optional: true, + Sensitive: true, + Validators: []validator.String{ + stringvalidator.LengthAtLeast(1), + }, + MarkdownDescription: "This is a access token that can be given to you by your admin under `Platform Configuration -> User Management -> Access Tokens`. This can also be sourced from the `JFROG_ACCESS_TOKEN` environment variable.", + }, + "oidc_provider_name": schema.StringAttribute{ + Optional: true, + Validators: []validator.String{ + stringvalidator.LengthAtLeast(1), + }, + MarkdownDescription: "OIDC provider name. See [Configure an OIDC Integration](https://jfrog.com/help/r/jfrog-platform-administration-documentation/configure-an-oidc-integration) for more details.", + }, + }, + MarkdownDescription: "The JFrog Mission Control provider provides resources to interact with Mission Control supported by JFrog Platform. See [official documentation](https://jfrog.com/help/r/get-started-with-the-jfrog-platform/jfrog-mission-control) for more details.", + } +} diff --git a/pkg/missioncontrol/resource_license_bucket.go b/pkg/missioncontrol/resource_license_bucket.go new file mode 100644 index 0000000..b9c4f4c --- /dev/null +++ b/pkg/missioncontrol/resource_license_bucket.go @@ -0,0 +1,351 @@ +package missioncontrol + +import ( + "bytes" + "context" + "fmt" + "os" + "path/filepath" + + "github.com/go-resty/resty/v2" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" + "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/path" + "github.com/hashicorp/terraform-plugin-framework/resource" + "github.com/hashicorp/terraform-plugin-framework/resource/schema" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" + "github.com/hashicorp/terraform-plugin-framework/types" + "github.com/jfrog/terraform-provider-shared/util" + utilfw "github.com/jfrog/terraform-provider-shared/util/fw" + validator_string "github.com/jfrog/terraform-provider-shared/validator/fw/string" + "github.com/samber/lo" +) + +const ( + licenseBucketsEndpoint = "mc/api/v1/buckets" + licenseBucketEndpoint = "mc/api/v1/buckets/{name}" +) + +var _ resource.Resource = &licenseBucketResource{} + +type licenseBucketResource struct { + ProviderData util.ProviderMetadata + TypeName string +} + +func NewLicenseBucketResource() resource.Resource { + return &licenseBucketResource{ + TypeName: "missioncontrol_license_bucket", + } +} + +func (r *licenseBucketResource) Metadata(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = r.TypeName +} + +func (r *licenseBucketResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { + resp.Schema = schema.Schema{ + Attributes: map[string]schema.Attribute{ + "id": schema.StringAttribute{ + Computed: true, + Description: "The identifier of this license bucket.", + }, + "name": schema.StringAttribute{ + Required: true, + Validators: []validator.String{ + stringvalidator.LengthAtLeast(1), + }, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + Description: "Name of the license bucket", + }, + "url": schema.StringAttribute{ + Optional: true, + Validators: []validator.String{ + validator_string.IsURLHttpOrHttps(), + stringvalidator.ConflictsWith(path.MatchRoot("file")), + }, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + Description: "Signed URL of the license bucket. Can't be set together with `file`.", + }, + "file": schema.StringAttribute{ + Optional: true, + Validators: []validator.String{ + stringvalidator.LengthAtLeast(1), + stringvalidator.ConflictsWith(path.MatchRoot("url")), + }, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + Description: "File path to the license bucket. Can't be set together with `url`.", + }, + "key": schema.StringAttribute{ + Required: true, + Validators: []validator.String{ + stringvalidator.LengthAtLeast(1), + }, + PlanModifiers: []planmodifier.String{ + stringplanmodifier.RequiresReplace(), + }, + Description: "License bucket key.", + }, + "subject": schema.StringAttribute{ + Computed: true, + Description: "The customer name of this license bucket.", + }, + "product_name": schema.StringAttribute{ + Computed: true, + }, + "product_id": schema.Int64Attribute{ + Computed: true, + }, + "license_type": schema.StringAttribute{ + Computed: true, + Description: "The license type of this license bucket.", + }, + "issued_date": schema.StringAttribute{ + Computed: true, + Description: "The issue date for this license bucket.", + }, + "valid_date": schema.StringAttribute{ + Computed: true, + Description: "The expiry date for this license bucket.", + }, + "quantity": schema.Int64Attribute{ + Computed: true, + Description: "The total number of licenses in this bucket.", + }, + "signature": schema.StringAttribute{ + Computed: true, + }, + "used": schema.Int64Attribute{ + Computed: true, + Description: "The number of used licenses in this bucket.", + }, + }, + MarkdownDescription: "Provides a JFrog [license bucket](https://jfrog.com/help/r/jfrog-platform-administration-documentation/manage-license-buckets) resource to manage license buckets.", + } +} + +type licenseBucketResourceModel struct { + ID types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` + URL types.String `tfsdk:"url"` + File types.String `tfsdk:"file"` + Key types.String `tfsdk:"key"` + Subject types.String `tfsdk:"subject"` + ProductName types.String `tfsdk:"product_name"` + ProductID types.Int64 `tfsdk:"product_id"` + LicenseType types.String `tfsdk:"license_type"` + IssuedDate types.String `tfsdk:"issued_date"` + ValidDate types.String `tfsdk:"valid_date"` + Signature types.String `tfsdk:"signature"` + Quantity types.Int64 `tfsdk:"quantity"` + Used types.Int64 `tfsdk:"used"` +} + +func (r *licenseBucketResourceModel) fromAPIModel(_ context.Context, apiModel *licenseBucketPostResponseAPIModel) (ds diag.Diagnostics) { + r.ID = types.StringValue(apiModel.ID) + r.Name = types.StringValue(apiModel.Name) + r.Subject = types.StringValue(apiModel.Subject) + r.ProductName = types.StringValue(apiModel.ProductName) + r.ProductID = types.Int64Value(apiModel.ProductID) + r.LicenseType = types.StringValue(apiModel.LicenseType) + r.IssuedDate = types.StringValue(apiModel.IssuedDate) + r.ValidDate = types.StringValue(apiModel.ValidDate) + r.Quantity = types.Int64Value(apiModel.Quantity) + r.Signature = types.StringValue(apiModel.Signature) + r.Used = types.Int64Value(apiModel.Used) + + return +} + +type licenseBucketPostRequestAPIModel struct { + Name string `json:"name"` + URL string `json:"url"` + Key string `json:"key"` +} + +type licenseBucketPostResponseAPIModel struct { + ID string `json:"identifier"` + Subject string `json:"subject"` + ProductName string `json:"product_name"` + ProductID int64 `json:"product_id"` + LicenseType string `json:"license_type"` + IssuedDate string `json:"issued_date"` + ValidDate string `json:"valid_date"` + Quantity int64 `json:"quantity"` + Signature string `json:"signature"` + Name string `json:"name"` + Used int64 `json:"used"` + URL string `json:"url"` +} + +type licenseBucketGetAPIModel struct { + Identifier string `json:"identifier"` + Name string `json:"name"` + Size int64 `json:"size"` + Type string `json:"license_type"` +} + +func (r *licenseBucketResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + r.ProviderData = req.ProviderData.(util.ProviderMetadata) +} + +func (r *licenseBucketResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + go util.SendUsageResourceCreate(ctx, r.ProviderData.Client.R(), r.ProviderData.ProductId, r.TypeName) + + var plan licenseBucketResourceModel + + resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) + if resp.Diagnostics.HasError() { + return + } + + var result licenseBucketPostResponseAPIModel + var response *resty.Response + var err error + if len(plan.URL.ValueString()) > 0 { + license := licenseBucketPostRequestAPIModel{ + Name: plan.Name.ValueString(), + URL: plan.URL.ValueString(), + Key: plan.Key.ValueString(), + } + + response, err = r.ProviderData.Client.R(). + SetBody(&license). + SetResult(&result). + Post(licenseBucketsEndpoint) + } else { + fileBytes, err := os.ReadFile(plan.File.ValueString()) + if err != nil { + utilfw.UnableToCreateResourceError(resp, err.Error()) + return + } + + response, err = r.ProviderData.Client.R(). + SetMultipartField( + "file", + filepath.Base(plan.File.ValueString()), + "application/octet-stream", + bytes.NewReader(fileBytes), + ). + SetMultipartFormData( + map[string]string{ + "name": plan.Name.ValueString(), + "key": plan.Key.ValueString(), + }, + ). + SetResult(&result). + Post(licenseBucketsEndpoint) + + if err != nil { + utilfw.UnableToCreateResourceError(resp, err.Error()) + return + } + } + + if err != nil { + utilfw.UnableToCreateResourceError(resp, err.Error()) + return + } + + if response.IsError() { + utilfw.UnableToCreateResourceError(resp, response.String()) + return + } + + // Convert from the API data model to the Terraform data model + // and refresh any attribute values. + resp.Diagnostics.Append(plan.fromAPIModel(ctx, &result)...) + if resp.Diagnostics.HasError() { + return + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) +} + +func (r *licenseBucketResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + go util.SendUsageResourceRead(ctx, r.ProviderData.Client.R(), r.ProviderData.ProductId, r.TypeName) + + var state licenseBucketResourceModel + + resp.Diagnostics.Append(req.State.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + var licenseBuckets []licenseBucketGetAPIModel + + response, err := r.ProviderData.Client.R(). + SetResult(&licenseBuckets). + Get(licenseBucketsEndpoint) + + if err != nil { + utilfw.UnableToRefreshResourceError(resp, err.Error()) + return + } + + if response.IsError() { + utilfw.UnableToRefreshResourceError(resp, response.String()) + return + } + + matchedBucket, ok := lo.Find( + licenseBuckets, + func(licenseBucket licenseBucketGetAPIModel) bool { + return licenseBucket.Name == state.Name.ValueString() + }, + ) + if !ok { + utilfw.UnableToRefreshResourceError(resp, fmt.Sprintf("bucket %s can't be found", state.Name.ValueString())) + return + } + + state.Name = types.StringValue(matchedBucket.Name) + state.Quantity = types.Int64Value(matchedBucket.Size) + state.LicenseType = types.StringValue(matchedBucket.Type) + + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *licenseBucketResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + // noop +} + +func (r *licenseBucketResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + go util.SendUsageResourceDelete(ctx, r.ProviderData.Client.R(), r.ProviderData.ProductId, r.TypeName) + + var state licenseBucketResourceModel + + diags := req.State.Get(ctx, &state) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + response, err := r.ProviderData.Client.R(). + SetPathParam("name", state.Name.ValueString()). + Delete(licenseBucketEndpoint) + if err != nil { + utilfw.UnableToDeleteResourceError(resp, err.Error()) + return + } + + if response.IsError() { + utilfw.UnableToDeleteResourceError(resp, response.String()) + return + } + + // If the logic reaches here, it implicitly succeeded and will remove + // the resource from state if there are no other errors. +} diff --git a/pkg/missioncontrol/resource_license_bucket_test.go b/pkg/missioncontrol/resource_license_bucket_test.go new file mode 100644 index 0000000..e34fd0f --- /dev/null +++ b/pkg/missioncontrol/resource_license_bucket_test.go @@ -0,0 +1,155 @@ +package missioncontrol_test + +import ( + "os" + "testing" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" + "github.com/hashicorp/terraform-plugin-testing/plancheck" + "github.com/jfrog/terraform-provider-shared/testutil" + "github.com/jfrog/terraform-provider-shared/util" +) + +// To execute this test, you need a signed license bucket URL and key from MyJFrog +// (Note: the signed URL will expired and require fetching a new one) +// Then set them as env vars before running the test +func TestAccLicenseBucket_url(t *testing.T) { + jfrogLicenseBucketURL := os.Getenv("JFROG_LICENSE_BUCKET_URL") + if jfrogLicenseBucketURL == "" { + t.Skipf("env var JFROG_LICENSE_BUCKET_URL not set") + } + + jfrogLicenseBucketKey := os.Getenv("JFROG_LICENSE_BUCKET_KEY") + if jfrogLicenseBucketKey == "" { + t.Skipf("env var JFROG_LICENSE_BUCKET_KEY not set") + } + + _, fqrn, resourceName := testutil.MkNames("test-license-bucket", "missioncontrol_license_bucket") + + temp := ` + resource "missioncontrol_license_bucket" "{{ .name }}" { + name = "{{ .name }}" + url = "{{ .url }}" + key = "{{ .key }}" + }` + + testData := map[string]string{ + "name": resourceName, + "url": jfrogLicenseBucketURL, + "key": jfrogLicenseBucketKey, + } + + config := util.ExecuteTemplate(resourceName, temp, testData) + + updatedTemp := ` + resource "missioncontrol_license_bucket" "{{ .name }}" { + name = "{{ .name }}-2" + url = "{{ .url }}" + key = "{{ .key }}" + }` + updatedConfig := util.ExecuteTemplate(resourceName, updatedTemp, testData) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProviders(), + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(fqrn, "name", testData["name"]), + resource.TestCheckResourceAttr(fqrn, "url", testData["url"]), + resource.TestCheckResourceAttr(fqrn, "key", testData["key"]), + resource.TestCheckResourceAttrSet(fqrn, "id"), + resource.TestCheckResourceAttr(fqrn, "subject", "JFROG TEST"), + resource.TestCheckResourceAttr(fqrn, "valid_date", "2025-01-04T00:00:00.000Z"), + resource.TestCheckResourceAttr(fqrn, "issued_date", "2023-12-23T08:46:48.000Z"), + resource.TestCheckResourceAttr(fqrn, "product_name", "Multiproducts"), + resource.TestCheckResourceAttr(fqrn, "product_id", "7"), + resource.TestCheckResourceAttr(fqrn, "license_type", "ENTERPRISE_PLUS_TRIAL"), + resource.TestCheckResourceAttr(fqrn, "quantity", "5"), + resource.TestCheckResourceAttr(fqrn, "used", "0"), + ), + }, + { + Config: updatedConfig, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(fqrn, plancheck.ResourceActionDestroyBeforeCreate), + }, + }, + }, + }, + }) +} + +// To execute this test, you need the encrypted file (download from the signed license bucket URL) +// and key from MyJFrog (Note: the signed URL will expired and require fetching a new one) +// Then set the file path and key as env vars before running the test +func TestAccLicenseBucket_file(t *testing.T) { + jfrogLicenseBucketFile := os.Getenv("JFROG_LICENSE_BUCKET_FILE") + if jfrogLicenseBucketFile == "" { + t.Skipf("env var JFROG_LICENSE_BUCKET_FILE not set") + } + + jfrogLicenseBucketKey := os.Getenv("JFROG_LICENSE_BUCKET_KEY") + if jfrogLicenseBucketKey == "" { + t.Skipf("env var JFROG_LICENSE_BUCKET_KEY not set") + } + + _, fqrn, resourceName := testutil.MkNames("test-license-bucket", "missioncontrol_license_bucket") + + temp := ` + resource "missioncontrol_license_bucket" "{{ .name }}" { + name = "{{ .name }}" + file = "{{ .file }}" + key = "{{ .key }}" + }` + + testData := map[string]string{ + "name": resourceName, + "file": jfrogLicenseBucketFile, + "key": jfrogLicenseBucketKey, + } + + config := util.ExecuteTemplate(resourceName, temp, testData) + + updatedTemp := ` + resource "missioncontrol_license_bucket" "{{ .name }}" { + name = "{{ .name }}-2" + file = "{{ .file }}" + key = "{{ .key }}" + }` + updatedConfig := util.ExecuteTemplate(resourceName, updatedTemp, testData) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV6ProviderFactories: testAccProviders(), + Steps: []resource.TestStep{ + { + Config: config, + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(fqrn, "name", testData["name"]), + resource.TestCheckNoResourceAttr(fqrn, "url"), + resource.TestCheckResourceAttr(fqrn, "key", testData["key"]), + resource.TestCheckResourceAttrSet(fqrn, "id"), + resource.TestCheckResourceAttr(fqrn, "subject", "JFROG TEST"), + resource.TestCheckResourceAttr(fqrn, "valid_date", "2025-01-04T00:00:00.000Z"), + resource.TestCheckResourceAttr(fqrn, "issued_date", "2023-12-23T08:46:48.000Z"), + resource.TestCheckResourceAttr(fqrn, "product_name", "Multiproducts"), + resource.TestCheckResourceAttr(fqrn, "product_id", "7"), + resource.TestCheckResourceAttr(fqrn, "license_type", "ENTERPRISE_PLUS_TRIAL"), + resource.TestCheckResourceAttr(fqrn, "quantity", "5"), + resource.TestCheckResourceAttr(fqrn, "used", "0"), + ), + }, + { + Config: updatedConfig, + ConfigPlanChecks: resource.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(fqrn, plancheck.ResourceActionDestroyBeforeCreate), + }, + }, + }, + }, + }) +} diff --git a/pkg/missioncontrol/util_test.go b/pkg/missioncontrol/util_test.go new file mode 100644 index 0000000..6291573 --- /dev/null +++ b/pkg/missioncontrol/util_test.go @@ -0,0 +1,84 @@ +package missioncontrol_test + +import ( + "os" + "sync" + "testing" + + "github.com/go-resty/resty/v2" + "github.com/hashicorp/terraform-plugin-framework/provider" + "github.com/hashicorp/terraform-plugin-framework/providerserver" + "github.com/hashicorp/terraform-plugin-go/tfprotov6" + "github.com/jfrog/terraform-provider-mission-control/pkg/missioncontrol" + "github.com/jfrog/terraform-provider-shared/client" +) + +// TestProvider PreCheck(t) must be called before using this provider instance. +var TestProvider provider.Provider + +// testAccProviderConfigure ensures Provider is only configured once +// +// The PreCheck(t) function is invoked for every test and this prevents +// extraneous reconfiguration to the same values each time. However, this does +// not prevent reconfiguration that may happen should the address of +// Provider be errantly reused in ProviderFactories. +var testAccProviderConfigure sync.Once + +// testAccPreCheck This function should be present in every acceptance test. +func testAccPreCheck(t *testing.T) { + // Since we are outside the scope of the Terraform configuration we must + // call Configure() to properly initialize the provider configuration. + testAccProviderConfigure.Do(func() { + restyClient := getTestResty(t) + + platformUrl := getPlatformUrl(t) + // Set custom base URL so repos that relies on it will work + // https://www.jfrog.com/confluence/display/JFROG/Artifactory+REST+API#ArtifactoryRESTAPI-UpdateCustomURLBase + _, err := restyClient.R(). + SetBody(platformUrl). + SetHeader("Content-Type", "text/plain"). + Put("/artifactory/api/system/configuration/baseUrl") + if err != nil { + t.Fatalf("failed to set custom base URL: %v", err) + } + }) +} + +func getTestResty(t *testing.T) *resty.Client { + var ok bool + + platformUrl := getPlatformUrl(t) + + restyClient, err := client.Build(platformUrl, "") + if err != nil { + t.Fatal(err) + } + + var accessToken string + if accessToken, ok = os.LookupEnv("JFROG_ACCESS_TOKEN"); !ok { + t.Fatal("JFROG_ACCESS_TOKEN must be set for acceptance tests") + } + restyClient, err = client.AddAuth(restyClient, "", accessToken) + if err != nil { + t.Fatal(err) + } + + return restyClient +} + +func getPlatformUrl(t *testing.T) string { + platformUrl, ok := os.LookupEnv("JFROG_URL") + if !ok { + t.Fatal("JFROG_URL must be set for acceptance tests") + } + + return platformUrl +} + +func testAccProviders() map[string]func() (tfprotov6.ProviderServer, error) { + TestProvider = missioncontrol.NewProvider()() + + return map[string]func() (tfprotov6.ProviderServer, error){ + "missioncontrol": providerserver.NewProtocol6WithError(TestProvider), + } +} diff --git a/sample.tf b/sample.tf new file mode 100644 index 0000000..7819ea5 --- /dev/null +++ b/sample.tf @@ -0,0 +1,24 @@ +terraform { + required_providers { + missioncontrol = { + source = "jfrog/mission-control" + version = "1.0.0" + } + } +} + +variable "jfrog_url" { + type = string + default = "https://my.jfrog.io" +} + +provider "missioncontrol" { + url = "${var.jfrog_url}" + // supply JFROG_ACCESS_TOKEN as env var +} + +resource "missioncontrol_license_bucket" "my-license-bucket" { + name = "my-license-bucket" + url = "https://buckets.jfrog.io/download/...63aeb8c664" + key = "my-license-bucket-key" +} \ No newline at end of file diff --git a/scripts/access.config.patch.yml b/scripts/access.config.patch.yml new file mode 100644 index 0000000..8b7ce1b --- /dev/null +++ b/scripts/access.config.patch.yml @@ -0,0 +1,11 @@ +token: + persistency: + persistent-expiry-threshold: 10800 # Available from Artifactory 7.8.0 - (seconds) token with expiry (expirationTime-issuedAt) below this value will not be persistent. set to -1 to make all tokens persistent. lowering this value will effectively revoke all tokens with expiry below the old value and above the new revocable-expiry-threshold. +integrations-enabled: true +integration-templates: + - id: "1" + name: "Slack integration" + redirect-uri: "https:///v1/oauth2/login/redirect" + scope: "applied-permissions/user" +security: + tls: false diff --git a/scripts/get-access-key.sh b/scripts/get-access-key.sh new file mode 100644 index 0000000..0dafd85 --- /dev/null +++ b/scripts/get-access-key.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +function getAccessKey() { + local url=${1?You must supply the artifactory url to obtain an access key} + echo "### Generate Admin Access Key ###" > /dev/stderr + + local cookies + cookies=$(curl -s -c - "${url}/ui/api/v1/ui/auth/login?_spring_security_remember_me=false" \ + --header "accept: application/json, text/plain, */*" \ + --header "content-type: application/json;charset=UTF-8" \ + --header "x-requested-with: XMLHttpRequest" \ + -d '{"user":"admin","password":"password","type":"login"}' | grep TOKEN) + + local refresh_token + refresh_token=$(echo "${cookies}" | grep REFRESHTOKEN | awk '{print $7 }') + + local access_token + access_token=$(echo "${cookies}" | grep ACCESSTOKEN | awk '{print $7 }') + + local access_key + local scoped_access_key + access_key=$(curl -s -g --request GET "${url}/ui/api/v1/system/security/token?services[]=all" \ + --header "accept: application/json, text/plain, */*" \ + --header "x-requested-with: XMLHttpRequest" \ + --header "cookie: ACCESSTOKEN=${access_token}; REFRESHTOKEN=${refresh_token}") + + scoped_access_key=$(curl --location --request POST "${url}/access/api/v1/tokens" \ + --header "Authorization: Bearer ${access_key}" \ + --header "Content-Type: application/x-www-form-urlencoded" \ + --data-urlencode "expires_in=0" \ + --data-urlencode "username=admin" \ + --data-urlencode "scope=applied-permissions/admin" \ + --data-urlencode "description=Created_with_script_in_TF_provider" | jq -r .access_token) + + echo "${scoped_access_key}" +} \ No newline at end of file diff --git a/scripts/run-artifactory.sh b/scripts/run-artifactory.sh new file mode 100755 index 0000000..62be6b9 --- /dev/null +++ b/scripts/run-artifactory.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )" +source "${SCRIPT_DIR}/get-access-key.sh" +source "${SCRIPT_DIR}/wait-for-rt.sh" + +export ARTIFACTORY_VERSION=${ARTIFACTORY_VERSION:-7.84.15} +echo "ARTIFACTORY_VERSION=${ARTIFACTORY_VERSION}" > /dev/stderr + +set -euf + +sudo rm -rf ${SCRIPT_DIR}/artifactory/ + +mkdir -p ${SCRIPT_DIR}/artifactory/extra_conf +mkdir -p ${SCRIPT_DIR}/artifactory/var/etc/access + +cp ${SCRIPT_DIR}/artifactory.lic ${SCRIPT_DIR}/artifactory/extra_conf +cp ${SCRIPT_DIR}/system.yaml ${SCRIPT_DIR}/artifactory/var/etc/ +cp ${SCRIPT_DIR}/access.config.patch.yml ${SCRIPT_DIR}/artifactory/var/etc/access + +docker run -i --name artifactory -d --rm \ + -e JF_FRONTEND_FEATURETOGGLER_ACCESSINTEGRATION=true \ + -v ${SCRIPT_DIR}/artifactory/extra_conf:/artifactory_extra_conf \ + -v ${SCRIPT_DIR}/artifactory/var:/var/opt/jfrog/artifactory \ + -p 8081:8081 -p 8082:8082 \ + releases-docker.jfrog.io/jfrog/artifactory-pro:${ARTIFACTORY_VERSION} + +export ARTIFACTORY_URL=http://localhost:8081 +export ARTIFACTORY_UI_URL=http://localhost:8082 + +# Wait for Artifactory to start +waitForArtifactory "${ARTIFACTORY_URL}" "${ARTIFACTORY_UI_URL}" + +# With this trick you can do $(./run-artifactory-container.sh) and it will directly be setup for you without the terminal output +echo "export JFROG_ACCESS_TOKEN=$(getAccessKey "${ARTIFACTORY_UI_URL}")" diff --git a/scripts/system.yaml b/scripts/system.yaml new file mode 100755 index 0000000..4143ed4 --- /dev/null +++ b/scripts/system.yaml @@ -0,0 +1,19 @@ +## @formatter:off +## JFROG ARTIFACTORY SYSTEM CONFIGURATION FILE +## HOW TO USE: comment-out any field and keep the correct yaml indentation by deleting only the leading '#' character. +configVersion: 1 +## NOTE: JFROG_HOME is a place holder for the JFrog root directory containing the deployed product, the home directory for all JFrog products. +## Replace JFROG_HOME with the real path! For example, in RPM install, JFROG_HOME=/opt/jfrog + +## NOTE: Sensitive information such as passwords and join key are encrypted on first read. +## NOTE: The provided commented key and value is the default. + +## SHARED CONFIGURATIONS +## A shared section for keys across all services in this config +shared: + database: + ## To run Artifactory with any database other than PostgreSQL allowNonPostgresql set to true. + allowNonPostgresql: true + +mc: + enabled: true \ No newline at end of file diff --git a/scripts/wait-for-rt.sh b/scripts/wait-for-rt.sh new file mode 100755 index 0000000..bdc853b --- /dev/null +++ b/scripts/wait-for-rt.sh @@ -0,0 +1,18 @@ +function waitForArtifactory() { + local url=${1?You must supply the artifactory url} + local url_ui=${2?You must supply the artifactory UI url} + echo "### Wait for Artifactory to start at ${url} ###" > /dev/stderr + + until $(curl -sf -o /dev/null -m 5 ${url}/artifactory/api/system/ping/); do + printf '.' + sleep 5 + done + echo "" + + echo "### Waiting for Artifactory UI to start at ${url_ui} ###" + until $(curl -sf -o /dev/null -m 5 ${url_ui}/ui/login/); do + printf '.' + sleep 5 + done + echo "" +} \ No newline at end of file diff --git a/templates/index.md.tmpl b/templates/index.md.tmpl new file mode 100644 index 0000000..b271940 --- /dev/null +++ b/templates/index.md.tmpl @@ -0,0 +1,88 @@ +--- +layout: "" +page_title: "JFrog Mission Control Provider" +description: |- + The JFrog Mission Control provider provides resources to interact with features from JFrog Mission Control. +--- + +# JFrog Mission Control Provider + +The [JFrog](https://jfrog.com/) Mission Control provider is used to interact with the features from [JFrog Mission Control REST API](https://jfrog.com/help/r/jfrog-rest-apis/mission-control-rest-apis). The provider needs to be configured with the proper credentials before it can be used. + +Links to documentation for specific resources can be found in the table of contents to the left. + +## Example Usage + +{{tffile "examples/example.tf"}} + +## Authentication + +The JFrog Mission Control provider supports for the following types of authentication: +* Scoped token +* Terraform Cloud OIDC provider + +### Scoped Token + +JFrog scoped tokens may be used via the HTTP Authorization header by providing the `access_token` field to the provider block. Getting this value from the environment is supported with the `JFROG_ACCESS_TOKEN` environment variable. + +Usage: +```terraform +provider "missioncontrol" { + url = "my.jfrog.io" + access_token = "abc...xy" +} +``` + +### Terraform Cloud OIDC Provider + +If you are using this provider on Terraform Cloud and wish to use dynamic credentials instead of static access token for authentication with JFrog platform, you can leverage Terraform as the OIDC provider. + +To setup dynamic credentials, follow these steps: +1. Configure Terraform Cloud as a generic OIDC provider +2. Set environment variable in your Terraform Workspace +3. Setup Terraform Cloud in your configuration + +During the provider start up, if it finds env var `TFC_WORKLOAD_IDENTITY_TOKEN` it will use this token with your JFrog instance to exchange for a short-live access token. If that is successful, the provider will the access token for all subsequent API requests with the JFrog instance. + +#### Configure Terraform Cloud as generic OIDC provider + +Follow [confgure an OIDC integration](https://jfrog.com/help/r/jfrog-platform-administration-documentation/configure-an-oidc-integration). Enter a name for the provider, e.g. `terraform-cloud`. Use `https://app.terraform.io` for "Provider URL". Choose your own value for "Audience", e.g. `jfrog-terraform-cloud`. + +Then [configure an identity mapping](https://jfrog.com/help/r/jfrog-platform-administration-documentation/configure-identity-mappings) with an empty "Claims JSON" (`{}`), and select the "Token scope", "User", and "Service" as desired. + +#### Set environment variable in your Terraform Workspace + +In your workspace, add an environment variable `TFC_WORKLOAD_IDENTITY_AUDIENCE` with audience value (e.g. `jfrog-terraform-cloud`) from JFrog OIDC integration above. See [Manually Generating Workload Identity Tokens](https://developer.hashicorp.com/terraform/cloud-docs/workspaces/dynamic-provider-credentials/manual-generation) for more details. + +When a run starts on Terraform Cloud, it will create a workload identity token with the specified audience and assigns it to the environment variable `TFC_WORKLOAD_IDENTITY_TOKEN` for the provider to consume. + +#### Setup Terraform Cloud in your configuration + +Add `cloud` block to `terraform` block, and add `oidc_provider_name` attribute (from JFrog OIDC integration) to provider block: + +```terraform +terraform { + cloud { + organization = "my-org" + workspaces { + name = "my-workspace" + } + } + + required_providers { + missioncontrol = { + source = "jfrog/mission-control" + version = "1.0.0" + } + } +} + +provider "missioncontrol" { + url = "https://myinstance.jfrog.io" + oidc_provider_name = "terraform-cloud" +} +``` + +**Note:** Ensure `access_token` attribute is not set + +{{ .SchemaMarkdown | trimspace }} diff --git a/terraform-registry-manifest.json b/terraform-registry-manifest.json new file mode 100644 index 0000000..295001a --- /dev/null +++ b/terraform-registry-manifest.json @@ -0,0 +1,6 @@ +{ + "version": 1, + "metadata": { + "protocol_versions": ["6.0"] + } +} diff --git a/tools/tools.go b/tools/tools.go new file mode 100644 index 0000000..2844b66 --- /dev/null +++ b/tools/tools.go @@ -0,0 +1,8 @@ +//go:build tools + +package tools + +import ( + // document generation + _ "github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs" +)