Skip to content

Commit

Permalink
skip conditions that are not present in domain (#118)
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Avetisyan <[email protected]>
  • Loading branch information
havetisyan authored Jul 2, 2024
1 parent 3800398 commit f80a216
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 41 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GOPKGNAME = github.com/AthenZ/terraform-provider-athenz

export GOPATH ?= $(shell go env GOPATH)
export GOPATH ?= $(shell /usr/local/go/bin/go env GOPATH)

BINARY=terraform-provider-athenz
FMT_LOG=/tmp/fmt.log
Expand All @@ -23,14 +23,14 @@ ifndef SYS_TEST_KEY
endif

vet:
go vet $(GOPKGNAME)/...
/usr/local/go/bin/go vet $(GOPKGNAME)/...

fmt:
gofmt -d . >$(FMT_LOG)
/usr/local/go/bin/gofmt -d . >$(FMT_LOG)
@if [ -s $(FMT_LOG) ]; then echo gofmt FAIL; cat $(FMT_LOG); false; fi

goimports:
go install golang.org/x/tools/cmd/goimports
/usr/local/go/bin/go install golang.org/x/tools/cmd/goimports

go_import:
goimports -d . >$(GOIMPORTS_LOG)
Expand All @@ -44,18 +44,18 @@ build_linux:

install_local:
@echo VERSION: $(VERSION) OS_ARCH: $(OS_ARCH) GOOS: $(GOOS) GOARCH: $(GOARCH)
go build -o ${BINARY}
/usr/local/go/bin/go build -o ${BINARY}
mkdir -p ~/.terraform.d/plugins/yahoo/provider/athenz/${VERSION}/${OS_ARCH}
mv ${BINARY} ~/.terraform.d/plugins/yahoo/provider/athenz/${VERSION}/${OS_ARCH}

unit: vet fmt
export TF_ACC=false ; go test -v $(GOPKGNAME)/...
export TF_ACC=false ; /usr/local/go/bin/go test -v $(GOPKGNAME)/...

acc_test: vet fmt
@echo acc_test: cacert: $(SYS_TEST_CA_CERT)
@echo acc_test: cert: $(SYS_TEST_CERT)
@echo acc_test: key: $(SYS_TEST_KEY)
export MEMBER_1=terraform-provider.athenz_provider_foo MEMBER_2=user.github-7654321 ADMIN_USER=user.github-7654321 SHORT_ID=github-7654321 TOP_LEVEL_DOMAIN=terraformTest DELEGATED_DOMAIN=terraform-provider-delegate DOMAIN=terraform-provider PARENT_DOMAIN=terraform-provider SUB_DOMAIN=Test DOMAIN=terraform-provider export TF_ACC=true export ATHENZ_CA_CERT=$(SYS_TEST_CA_CERT) export ATHENZ_ZMS_URL=https://localhost:4443/zms/v1 export ATHENZ_CERT=$(SYS_TEST_CERT) export ATHENZ_KEY=$(SYS_TEST_KEY) ; go test -v $(GOPKGNAME)/...
export MEMBER_1=terraform-provider.athenz_provider_foo MEMBER_2=user.github-7654321 ADMIN_USER=user.github-7654321 SHORT_ID=github-7654321 TOP_LEVEL_DOMAIN=terraformTest DELEGATED_DOMAIN=terraform-provider-delegate DOMAIN=terraform-provider PARENT_DOMAIN=terraform-provider SUB_DOMAIN=Test DOMAIN=terraform-provider export TF_ACC=true export ATHENZ_CA_CERT=$(SYS_TEST_CA_CERT) export ATHENZ_ZMS_URL=https://localhost:4443/zms/v1 export ATHENZ_CERT=$(SYS_TEST_CERT) export ATHENZ_KEY=$(SYS_TEST_KEY) ; /usr/local/go/bin/go test -v $(GOPKGNAME)/...

test: unit

Expand Down
13 changes: 8 additions & 5 deletions athenz/assertion.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,14 @@ func flattenAssertionConditions(list []*zms.AssertionCondition) []interface{} {
c := make(map[string]interface{}, len(keys))
c["id"] = (int)(*condition.Id)
for _, key := range keys {
c[key] = []map[string]interface{}{
{
"operator": (int)(condition.ConditionsMap[zms.AssertionConditionKey(key)].Operator),
"value": (string)(condition.ConditionsMap[zms.AssertionConditionKey(key)].Value),
},
conditionKey, ok := condition.ConditionsMap[zms.AssertionConditionKey(key)]
if ok {
c[key] = []map[string]interface{}{
{
"operator": (int)(conditionKey.Operator),
"value": (string)(conditionKey.Value),
},
}
}
}
assertionConditions = append(assertionConditions, c)
Expand Down
2 changes: 1 addition & 1 deletion execution/pr-acc-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ wget -O "${SD_ROOT_DIR}/terraform/terraform_${VERSION}_${OS_ARCH}.zip" "https://
unzip "${SD_ROOT_DIR}/terraform/terraform_${VERSION}_${OS_ARCH}.zip" -d ${SD_ROOT_DIR}/terraform
ls ${SD_ROOT_DIR}/terraform
chmod +x ${SD_ROOT_DIR}/terraform/terraform
sudo ln -sf ${SD_ROOT_DIR}/terraform/terraform /usr/local/bin
ln -sf ${SD_ROOT_DIR}/terraform/terraform /usr/local/bin
ls /usr/local/bin
terraform -v

Expand Down
2 changes: 1 addition & 1 deletion execution/sys-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if [[ ! $(which terraform) ]]; then
unzip "${SD_ROOT_DIR}/terraform/terraform_${VERSION}_${OS_ARCH}.zip" -d ${SD_ROOT_DIR}/terraform
ls ${SD_ROOT_DIR}/terraform
chmod +x ${SD_ROOT_DIR}/terraform/terraform
sudo ln -sf ${SD_ROOT_DIR}/terraform/terraform /usr/local/bin
ln -sf ${SD_ROOT_DIR}/terraform/terraform /usr/local/bin
ls /usr/local/bin
terraform -v
fi
Expand Down
16 changes: 3 additions & 13 deletions screwdriver.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

shared:
image: vespaengine/vespa-build-centos7:latest
image: eclipse-temurin:11-jdk-focal
settings:
email:
addresses: [[email protected]]
Expand Down Expand Up @@ -30,12 +30,7 @@ jobs:
- SD_DEPLOY_KEY
steps:
- install-deps: |
./scripts/goupdate.sh
set -e
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum -y install wget docker-ce-cli
docker system info
ls -la $SD_DIND_SHARE_PATH
./scripts/install_deps.sh
- tag-prerelease-version: |
./scripts/git-tag.sh -r prerelease -t true
- run-tests-prerelease-version: |
Expand All @@ -58,12 +53,7 @@ jobs:
requires: [~pr]
steps:
- install-deps: |
./scripts/goupdate.sh
set -e
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum -y install wget docker-ce-cli
docker system info
ls -la $SD_DIND_SHARE_PATH
./scripts/install_deps.sh
- unit-test: |
make unit
./execution/pr-acc-test.sh
1 change: 0 additions & 1 deletion scripts/git-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ if [ -z $RELEASE_TYPE ]; then
fi

echo "Downloading gitversion"
yum install -y wget
wget -O - https://github.com/screwdriver-cd/gitversion/releases/latest |
egrep -o 'https://github.com/screwdriver-cd/gitversion/releases/expanded_assets/v[0-9.]*' |
wget -O - -i - |
Expand Down
13 changes: 0 additions & 13 deletions scripts/goupdate.sh

This file was deleted.

41 changes: 41 additions & 0 deletions scripts/install_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

set -e

apt-get update
apt-get clean
apt-get autoremove

echo "-----------------Install libs: -----------------"
apt-get install -y libaio1 libnuma-dev build-essential libncurses5 aptitude net-tools gawk unzip

echo "-----------------Install gcc: -----------------"
apt-get install -y software-properties-common
add-apt-repository -y ppa:ubuntu-toolchain-r/test
apt-get install -y gcc
apt-get install -y g++

echo "-----------------Install golang: -----------------"
LATEST_GO_VERSION="$(curl --silent https://go.dev/VERSION?m=text | grep go)";

wget https://go.dev/dl/${LATEST_GO_VERSION}.linux-amd64.tar.gz
tar -C /usr/local -xzf ${LATEST_GO_VERSION}.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin

echo "-----------------Install Docker: -----------------"
# Add Docker's official GPG key:
apt-get update
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
apt-key fingerprint 0EBFCD88

add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin
docker system info
ls -la $SD_DIND_SHARE_PATH

# check all installed dependencies
echo "-----------------Golang Version: -----------------"
go version
echo "-----------------Docker Version: -----------------"
docker version

0 comments on commit f80a216

Please sign in to comment.