Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/go_modules/github.com/jfrog/ter…
Browse files Browse the repository at this point in the history
…raform-provider-shared-1.25.2
  • Loading branch information
alexhung authored May 20, 2024
2 parents b7519f1 + c238ddb commit a999176
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 56 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ lib/
coverage.txt
.scannerwork
*.code-workspace
scripts/artifactory/
36 changes: 23 additions & 13 deletions .jfrog-pipelines/TFproviderTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pipelines:
- integrationName: partnership_slack
timeoutSeconds: 172800 # 2 days
execution:
onExecute:
onStart:
- echo "Sending status to GitHub."
- export STATE="pending"
- export DESCRIPTION="Pipeline run is in progress."
Expand Down Expand Up @@ -124,7 +124,8 @@ pipelines:
- cp sample.tf.tmp sample.tf && rm sample.tf.tmp
- cat sample.tf
- echo "Save RT licenses from the variable to the license file"
- echo ${int_partnership_rt_cluster_license_5licenses} > scripts/artifactory.lic
- mkdir -p ${res_GitHubTFProviderRepoJFrog_resourcePath}/scripts/artifactory/extra_conf
- echo ${int_partnership_rt_cluster_license_5licenses} > ${res_GitHubTFProviderRepoJFrog_resourcePath}/scripts/artifactory/extra_conf/artifactory.lic
- echo "Set Artifactory version, run RT in a container"
- >-
if [[ ${USE_LATEST_RT_VERSION} == "true" ]]; then
Expand All @@ -137,29 +138,38 @@ pipelines:
echo "Artifactory version: "${ARTIFACTORY_VERSION}
fi
- export ARTIFACTORY_CONTAINER_NAME=artifactory
- mkdir -p ${res_GitHubTFProviderRepoJFrog_resourcePath}/scripts/artifactory/var/etc/access
- chown -R 1030:1030 ${res_GitHubTFProviderRepoJFrog_resourcePath}/scripts/artifactory/var
- cp ${res_GitHubTFProviderRepoJFrog_resourcePath}/scripts/system.yaml ${res_GitHubTFProviderRepoJFrog_resourcePath}/scripts/artifactory/var/etc/system.yaml
- cp ${res_GitHubTFProviderRepoJFrog_resourcePath}/scripts/access.config.patch.yml ${res_GitHubTFProviderRepoJFrog_resourcePath}/scripts/artifactory/var/etc/access/access.config.patch.yml
- >-
docker run -i --name ${ARTIFACTORY_CONTAINER_NAME} -t -d --rm -v "${res_GitHubTFProviderRepoJFrog_resourcePath}/scripts/artifactory.lic:/artifactory_extra_conf/artifactory.lic:ro" \
-p 8082:8082 releases-docker.jfrog.io/jfrog/artifactory-pro:${ARTIFACTORY_VERSION}
docker run -i --name ${ARTIFACTORY_CONTAINER_NAME} -t -d --rm \
-e JF_FRONTEND_FEATURETOGGLER_ACCESSINTEGRATION=true \
-v ${res_GitHubTFProviderRepoJFrog_resourcePath}/scripts/artifactory/extra_conf:/artifactory_extra_conf \
-v ${res_GitHubTFProviderRepoJFrog_resourcePath}/scripts/artifactory/var:/var/opt/jfrog/artifactory \
-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_CONTAINER_NAME})
- echo "Using ${LOCALHOST} as 'localhost' ip address"
- echo "Waiting for Artifactory to start (doesn't reflect the start of the UI!)"
- export ARTIFACTORY_URL="http://${LOCALHOST}:8082"
- >-
until curl -sf -u admin:password ${ARTIFACTORY_URL}/artifactory/api/system/licenses/; do
until $(curl -sf -m 5 ${ARTIFACTORY_URL}/artifactory/api/system/ping/); do
printf '.'
sleep 4
sleep 5
done
- echo "Add variables needed to run Terraform Provider"
- export ARTIFACTORY_USERNAME=admin
- export ARTIFACTORY_PASSWORD=password
- echo "Get cookie to generate Access token. We need a pause to let UI come up to get cookies"
- echo "Waiting for Artifactory UI to start"
- >-
until curl -sf -u admin:password ${ARTIFACTORY_URL}/ui/login/; do
until $(curl -sf -m 5 ${ARTIFACTORY_URL}/ui/login/); do
printf '.'
sleep 4
sleep 5
done
- sudo curl ${ARTIFACTORY_URL}/router/api/v1/system/health
- curl ${ARTIFACTORY_URL}/router/api/v1/system/health
- echo "Add variables needed to run Terraform Provider"
- export ARTIFACTORY_USERNAME=admin
- export ARTIFACTORY_PASSWORD=password
- echo "Get cookie to generate Access token"
- >-
export COOKIES=$(curl -c - "${ARTIFACTORY_URL}/ui/api/v1/ui/auth/login?_spring_security_remember_me=false" \
--header "accept: application/json, text/plain, */*" \
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 10.7.7 (May 17, 2024). Tested on Artifactory 7.84.10 with Terraform CLI v1.8.3

BUG FIXES:

* provider: Fix inability to use `api_key` attribute without also setting `access_token` attribute. Issue: [#966](https://github.com/jfrog/terraform-provider-artifactory/issues/966) PR: [#967](https://github.com/jfrog/terraform-provider-artifactory/pull/967)

## 10.7.6 (May 10, 2024)

BUG FIXES:
Expand Down
15 changes: 8 additions & 7 deletions pkg/artifactory/provider/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (p *ArtifactoryProvider) Schema(ctx context.Context, req provider.SchemaReq
},
"api_key": schema.StringAttribute{
Description: "API key. If `access_token` attribute, `JFROG_ACCESS_TOKEN` or `ARTIFACTORY_ACCESS_TOKEN` environment variable is set, the provider will ignore this attribute.",
DeprecationMessage: "An upcoming version will support the option to block the usage/creation of API Keys (for admins to set on their platform). In a future version (scheduled for end of Q3, 2023), the option to disable the usage/creation of API Keys will be available and set to disabled by default. Admins will be able to enable the usage/creation of API Keys. By end of Q4 2024, API Keys will be deprecated all together and the option to use them will no longer be available. See [JFrog API deprecation process](https://jfrog.com/help/r/jfrog-platform-administration-documentation/jfrog-api-key-deprecation-process) for more details.",
DeprecationMessage: "An upcoming version will support the option to block the usage/creation of API Keys (for admins to set on their platform).\nIn a future version (scheduled for end of Q3, 2023), the option to disable the usage/creation of API Keys will be available and set to disabled by default. Admins will be able to enable the usage/creation of API Keys.\nBy end of Q4 2024, API Keys will be deprecated all together and the option to use them will no longer be available. See [JFrog API deprecation process](https://jfrog.com/help/r/jfrog-platform-administration-documentation/jfrog-api-key-deprecation-process) for more details.",
Optional: true,
Sensitive: true,
},
Expand Down Expand Up @@ -139,17 +139,18 @@ func (p *ArtifactoryProvider) Configure(ctx context.Context, req provider.Config
accessToken = config.AccessToken.ValueString()
}

if accessToken == "" {
apiKey := config.ApiKey.ValueString()

if apiKey == "" && accessToken == "" {
resp.Diagnostics.AddError(
"Missing JFrog Access Token",
"While configuring the provider, the Access Token was not found in "+
"the JFROG_ACCESS_TOKEN/ARTIFACTORY_ACCESS_TOKEN environment variable or provider "+
"configuration block access_token attribute.",
"Missing JFrog API key or Access Token",
"While configuring the provider, the API key or Access Token was not found in "+
"the environment variables or provider configuration attributes.",
)
return
}

restyClient, err = client.AddAuth(restyClient, config.ApiKey.ValueString(), accessToken)
restyClient, err = client.AddAuth(restyClient, apiKey, accessToken)
if err != nil {
resp.Diagnostics.AddError(
"Error adding Auth to Resty client",
Expand Down
3 changes: 1 addition & 2 deletions scripts/access.config.patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ integration-templates:
- id: "1"
name: "Slack integration"
redirect-uri: "https://<your saas connector hostname>/v1/oauth2/login/redirect"
scope: "applied-permissions/user"

scope: "applied-permissions/user"
21 changes: 0 additions & 21 deletions scripts/docker-compose.yml

This file was deleted.

8 changes: 6 additions & 2 deletions scripts/run-artifactory-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ echo "ARTIFACTORY_VERSION=${ARTIFACTORY_VERSION}" > /dev/stderr

set -euf

docker run -i -t -d --rm -v "${SCRIPT_DIR}/artifactory.lic:/artifactory_extra_conf/artifactory.lic:ro" \
-p8081:8081 -p8082:8082 -p8080:8080 "releases-docker.jfrog.io/jfrog/artifactory-pro:${ARTIFACTORY_VERSION}"
docker run -i --name artifactory-1 -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
Expand Down
14 changes: 13 additions & 1 deletion scripts/run-artifactory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@ echo "ARTIFACTORY_VERSION=${ARTIFACTORY_VERSION}"

set -euf

docker-compose --project-directory "${SCRIPT_DIR}" up -d --remove-orphans
docker run -i --name artifactory-1 -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}

docker run -i --name artifactory-2 -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 9081:8081 -p 9082:8082 \
releases-docker.jfrog.io/jfrog/artifactory-pro:${ARTIFACTORY_VERSION}

ARTIFACTORY_URL_1=http://localhost:8081
ARTIFACTORY_UI_URL_1=http://localhost:8082
Expand Down
17 changes: 15 additions & 2 deletions scripts/system.yaml
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## @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:
featureToggler:
accessIntegration: true
database:
## To run Artifactory with any database other than PostgreSQL allowNonPostgresql set to true.
allowNonPostgresql: true
16 changes: 8 additions & 8 deletions scripts/wait-for-rt.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,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 ###" > /dev/stderr
echo "### Wait for Artifactory to start at ${url} ###" > /dev/stderr

until curl -sf -u admin:password ${url}/artifactory/api/system/ping/; do
printf '.' > /dev/stderr
sleep 4
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 ###"
until curl -sf -o /dev/null -u admin:password ${url_ui}/ui/login/; do
printf '.' > /dev/stderr
sleep 4
echo "### Waiting for Artifactory UI to start at ${url} ###"
until $(curl -sf -o /dev/null -m 5 ${url_ui}/ui/login/); do
printf '.'
sleep 5
done
echo ""
}

0 comments on commit a999176

Please sign in to comment.