Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Upgrade to latest ACM Generator plugin version
Browse files Browse the repository at this point in the history
Added multi platform support for MacOS
Added compilation of plugins (PGT and ACM Gen)
  • Loading branch information
edcdavid committed Mar 28, 2024
1 parent c7013af commit 464a49d
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 31 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Test Incoming Changes

on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]
workflow_dispatch:
env:
TERM: xterm-color
Expand Down Expand Up @@ -98,8 +98,11 @@ jobs:
env:
SHELL: /bin/bash

- name: Build binary
run: make build
- name: Build binary linux-amd64
run: make build-linux-amd64

- name: Basic test
run: make test
- name: Build binary darwin-arm64
run: sudo make clean && make build-darwin-arm64

- name: Build local architecture and Basic test
run: sudo make clean && make test
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,25 @@ GO_PACKAGES=$(shell go list ./... | grep -v vendor)
# Runs configured linters
lint:
golangci-lint run --timeout 10m0s
build:
build: build-plugins
go build -o pgt2acm
build-linux-amd64: build-plugins-linux-amd64
GOOS=linux GOARCH=amd64 go build -o pgt2acm
build-darwin-arm64: build-plugins-darwin-arm64
GOOS=darwin GOARCH=arm64 go build -o pgt2acm
test: build
scripts/test.sh
clean:
rm -r test/acmgen-output
rm pgt2acm
rm -r test/acmgen-output || true
rm pgt2acm || true
rm -rf build || true
fetch-schema:
kustomize openapi fetch > test/cluster-schema.json
vet:
go vet ${GO_PACKAGES}
build-plugins-darwin-arm64: clean
GOOS=darwin GOARCH=arm64 scripts/build-plugins.sh
build-plugins-linux-amd64: clean
GOOS=linux GOARCH=amd64 scripts/build-plugins.sh
build-plugins: clean
scripts/build-plugins.sh
Binary file not shown.
Binary file not shown.
22 changes: 22 additions & 0 deletions scripts/build-plugins.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

ROOT=$(pwd)
POLICY_GENERATOR_TAG=release-2.10

rm -rf build || true
mkdir build
cd build || exit 1
# Download ACM Policy Generator plugin repo
git clone --branch="$POLICY_GENERATOR_TAG" --depth 1 https://github.com/stolostron/policy-generator-plugin
# Download PGT repo
git clone --depth 1 https://github.com/openshift-kni/cnf-features-deploy.git
# Build latest Policy Generator Template plugin executable
cd cnf-features-deploy/ztp/policygenerator || exit 1
make build
cp policygenerator "$ROOT"/kustomize/ran.openshift.io/v1/policygentemplate/PolicyGenTemplate
cd - || exit 1

# Build ACM Policy Generator plugin executable
cd policy-generator-plugin/ || exit 1
API_PLUGIN_PATH="." make build
cp PolicyGenerator "$ROOT"/kustomize/policy.open-cluster-management.io/v1/policygenerator/PolicyGenerator
2 changes: 1 addition & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
rm -rf test/acmgen-output
mkdir test/acmgen-output
cp -r test/init-source-crs test/acmgen-output/source-crs
./pgt2acm -i test/pgt-input -o test/acmgen-output -s test/newptpconfig-schema.json -k PtpConfig -n "" -w
./pgt2acm -i test/pgt-input -o test/acmgen-output -s test/newptpconfig-schema.json -k PtpConfig -n ""

if diff -r test/acmgen-output test/acmgen-expected-output; then
echo "Test Passed"
Expand Down
9 changes: 8 additions & 1 deletion test/acmgen-expected-output/acm-pgt-example-ptp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ placementBindingDefaults:
policyDefaults:
namespace: ztp-group
placement:
placementPath: group-du-standard-latest-config-policy-placement.yaml
labelSelector:
matchExpressions:
- key: du-profile
operator: In
values:
- latest
- key: group-du-standard
operator: Exists
remediationAction: inform
severity: low
namespaceSelector:
Expand Down

This file was deleted.

0 comments on commit 464a49d

Please sign in to comment.