Skip to content

Commit b62a804

Browse files
Update the plugin name to opa-envoy
This OPA plugin implements the Envoy External Authorization API and hence the current plugin name could be considered a misnomer. This commit updates the plugin name to opa-envoy-plugin. It also includes examples of using the plugin with different Envoy-based service meshes like Istio. Signed-off-by: Ashutosh Narkar <[email protected]>
1 parent b0118d1 commit b62a804

22 files changed

+1048
-479
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
sudo: required
22
language: go
3-
go_import_path: github.com/open-policy-agent/opa-istio-plugin
3+
go_import_path: github.com/open-policy-agent/opa-envoy-plugin
44
go:
55
- '1.13'
66
services:
@@ -16,7 +16,7 @@ jobs:
1616
skip_cleanup: true
1717
script: docker login -u $DOCKER_USER -p $DOCKER_PASSWORD && make deploy-travis
1818
on:
19-
repo: open-policy-agent/opa-istio-plugin
19+
repo: open-policy-agent/opa-envoy-plugin
2020
branch: master
2121
tags: false
2222
- stage: e2e
@@ -41,6 +41,6 @@ jobs:
4141
- curl -L https://git.io/getLatestIstio | ISTIO_VERSION=${ISTIO_VERSION} sh - && mv istio-${ISTIO_VERSION} /tmp && cd /tmp/istio-${ISTIO_VERSION} && for i in install/kubernetes/helm/istio-init/files/crd*yaml; do kubectl apply -f $i; done && kubectl apply -f install/kubernetes/istio-demo.yaml && cd -
4242
- kubectl -n istio-system wait --for=condition=available --timeout=600s --all deployment
4343
script:
44-
- make update-quickstart-version && make test-e2e
44+
- make update-istio-quickstart-version && make test-e2e
4545
after_script:
4646
- kind delete cluster

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ MAINTAINER Ashutosh Narkar <[email protected]>
88

99
WORKDIR /app
1010

11-
COPY opa_istio_linux_GOARCH /app
11+
COPY opa_envoy_linux_GOARCH /app
1212

13-
ENTRYPOINT ["./opa_istio_linux_GOARCH"]
13+
ENTRYPOINT ["./opa_envoy_linux_GOARCH"]
1414

1515
CMD ["run"]

Makefile

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# Use of this source code is governed by an Apache2
33
# license that can be found in the LICENSE file.
44

5-
VERSION := $(shell ./build/get-opa-version.sh)-istio$(shell ./build/get-plugin-rev.sh)
5+
VERSION := $(shell ./build/get-opa-version.sh)-envoy$(shell ./build/get-plugin-rev.sh)
6+
VERSION_ISTIO := $(shell ./build/get-opa-version.sh)-istio$(shell ./build/get-plugin-rev.sh)
67

78
PACKAGES := $(shell go list ./.../ | grep -v 'vendor')
89

@@ -11,7 +12,7 @@ GOARCH := $(shell go env GOARCH)
1112
GOOS := $(shell go env GOOS)
1213
DISABLE_CGO := CGO_ENABLED=0
1314

14-
BIN := opa_istio_$(GOOS)_$(GOARCH)
15+
BIN := opa_envoy_$(GOOS)_$(GOARCH)
1516

1617
REPOSITORY := openpolicyagent
1718
IMAGE := $(REPOSITORY)/opa
@@ -30,7 +31,7 @@ export GO15VENDOREXPERIMENT
3031

3132
.PHONY: all build build-mac build-linux clean check check-fmt check-vet check-lint \
3233
deps deploy-travis generate image image-quick push push-latest tag-latest \
33-
test test-cluster test-e2e update-opa update-quickstart-version version
34+
test test-cluster test-e2e update-opa update-istio-quickstart-version version
3435

3536
######################################################
3637
#
@@ -50,7 +51,7 @@ generate:
5051
$(GO) generate ./...
5152

5253
build: generate
53-
$(GO) build -o $(BIN) -ldflags $(LDFLAGS) ./cmd/opa-istio-plugin/...
54+
$(GO) build -o $(BIN) -ldflags $(LDFLAGS) ./cmd/opa-envoy-plugin/...
5455

5556
build-mac:
5657
@$(MAKE) build GOOS=darwin
@@ -65,23 +66,27 @@ image:
6566
image-quick:
6667
sed -e 's/GOARCH/$(GOARCH)/g' Dockerfile > .Dockerfile_$(GOARCH)
6768
docker build -t $(IMAGE):$(VERSION) -f .Dockerfile_$(GOARCH) .
69+
docker tag $(IMAGE):$(VERSION) $(IMAGE):$(VERSION_ISTIO)
6870

6971
push:
7072
docker push $(IMAGE):$(VERSION)
73+
docker push $(IMAGE):$(VERSION_ISTIO)
7174

7275
tag-latest:
76+
docker tag $(IMAGE):$(VERSION) $(IMAGE):latest-envoy
7377
docker tag $(IMAGE):$(VERSION) $(IMAGE):latest-istio
7478

7579
push-latest:
80+
docker push $(IMAGE):latest-envoy
7681
docker push $(IMAGE):latest-istio
7782

7883
deploy-travis: image-quick push tag-latest push-latest
7984

8085
update-opa:
8186
@./build/update-opa-version.sh $(TAG)
8287

83-
update-quickstart-version:
84-
sed -i "/opa_container/{N;s/openpolicyagent\/opa:.*/openpolicyagent\/opa:latest-istio\"\,/;}" quick_start.yaml
88+
update-istio-quickstart-version:
89+
sed -i "/opa_container/{N;s/openpolicyagent\/opa:.*/openpolicyagent\/opa:latest-istio\"\,/;}" examples/istio/quick_start.yaml
8590

8691
test: generate
8792
$(DISABLE_CGO) $(GO) test -v -bench=. $(PACKAGES)

README.md

Lines changed: 206 additions & 181 deletions
Large diffs are not rendered by default.

build/check-fmt.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env bash
22

3-
OPA_ISTIO_DIR=$(dirname "${BASH_SOURCE}")/..
4-
source $OPA_ISTIO_DIR/build/utils.sh
3+
OPA_ENVOY_DIR=$(dirname "${BASH_SOURCE}")/..
4+
source $OPA_ENVOY_DIR/build/utils.sh
55

6-
function opa-istio-plugin::check_fmt() {
6+
function opa-envoy-plugin::check_fmt() {
77
exec 5>&1
88
exit_code=0
9-
for pkg in $(opa-istio-plugin::go_packages); do
10-
for file in $(opa-istio-plugin::go_files_in_package $pkg); do
9+
for pkg in $(opa-envoy-plugin::go_packages); do
10+
for file in $(opa-envoy-plugin::go_files_in_package $pkg); do
1111
__diff=$(gofmt -d $file | tee >(cat - >&5))
1212
if [ ! -z "$__diff" ]; then
1313
exit_code=1
@@ -17,4 +17,4 @@ function opa-istio-plugin::check_fmt() {
1717
exit $exit_code
1818
}
1919

20-
opa-istio-plugin::check_fmt
20+
opa-envoy-plugin::check_fmt

build/check-lint.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
#!/usr/bin/env bash
22

3-
OPA_ISTIO_DIR=$(
3+
OPA_ENVOY_DIR=$(
44
dir=$(dirname "${BASH_SOURCE}")/..
55
cd "$dir"
66
pwd
77
)
8-
source $OPA_ISTIO_DIR/build/utils.sh
8+
source $OPA_ENVOY_DIR/build/utils.sh
99

1010

11-
function opa-istio-plugin::check_lint() {
11+
function opa-envoy-plugin::check_lint() {
1212
exec 5>&1
1313
exit_code=0
14-
for pkg in $(opa-istio-plugin::go_packages); do
14+
for pkg in $(opa-envoy-plugin::go_packages); do
1515
__output=$(golint $pkg | tee >(cat - >&5))
1616
if [ ! -z "$__output" ]; then
1717
exit_code=1
@@ -20,4 +20,4 @@ function opa-istio-plugin::check_lint() {
2020
exit $exit_code
2121
}
2222

23-
opa-istio-plugin::check_lint
23+
opa-envoy-plugin::check_lint

build/check-vet.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
#!/usr/bin/env bash
22

3-
OPA_ISTIO_DIR=$(
3+
OPA_ENVOY_DIR=$(
44
dir=$(dirname "${BASH_SOURCE}")/..
55
cd "$dir"
66
pwd
77
)
8-
source $OPA_ISTIO_DIR/build/utils.sh
8+
source $OPA_ENVOY_DIR/build/utils.sh
99

10-
function opa-istio-plugin::check_vet() {
10+
function opa-envoy-plugin::check_vet() {
1111
exec 5>&1
1212
rc=0
1313
exit_code=0
14-
for pkg in $(opa-istio-plugin::go_packages); do
14+
for pkg in $(opa-envoy-plugin::go_packages); do
1515
go vet $pkg || rc=$?
1616
if [[ $rc != 0 ]]; then
1717
exit_code=1
@@ -20,4 +20,4 @@ function opa-istio-plugin::check_vet() {
2020
exit $exit_code
2121
}
2222

23-
opa-istio-plugin::check_vet
23+
opa-envoy-plugin::check_vet

build/install-istio-with-kind.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set -x
77
GOARCH=$(go env GOARCH)
88
GOOS=$(go env GOOS)
99
KIND_VERSION=0.4.0
10-
ISTIO_VERSION=1.2.5
10+
ISTIO_VERSION=1.5.0
1111

1212
# Download and install kind
1313
curl -L https://github.com/kubernetes-sigs/kind/releases/download/v${KIND_VERSION}/kind-${GOOS}-${GOARCH} --output kind && chmod +x kind && sudo mv kind /usr/local/bin/

build/travis-utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Travis-CI sets TRAVIS_PULL_REQUEST=false when the build is triggered for
2-
# changes pushed into github.com/open-policy-agent/opa-istio-plugin
2+
# changes pushed into github.com/open-policy-agent/opa-envoy-plugin
33
function is_travis_push_env() {
44
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
55
return 0

build/update-opa-version.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ if [ $? -eq 0 ]; then
2626
tag=$(echo $1 | cut -c 2-) # Remove 'v' in Tag. Eg. v0.8.0 -> 0.8.0
2727

2828
# update plugin image version in README
29-
sed -i.bak "s/openpolicyagent\/opa:.*/openpolicyagent\/opa:$tag-istio/" README.md && rm README.md.bak
29+
sed -i.bak "s/openpolicyagent\/opa:.*/openpolicyagent\/opa:$tag-envoy/" README.md && rm README.md.bak
3030

31-
# update plugin image version in quick_start.yaml
32-
sed -i.bak "/opa_container/{N;s/openpolicyagent\/opa:.*/openpolicyagent\/opa:$tag-istio\"\,/;}" quick_start.yaml && rm quick_start.yaml.bak
33-
sed -i.bak "s/image: openpolicyagent\/opa:.*/image: openpolicyagent\/opa:$tag/" quick_start.yaml quick_start.yaml && rm quick_start.yaml.bak
31+
# update plugin image version in quick_start.yaml for Envoy
32+
sed -i.bak "s/image: openpolicyagent\/opa:.*/image: openpolicyagent\/opa:$tag-envoy/" quick_start.yaml && rm quick_start.yaml.bak
33+
34+
# update plugin image version in quick_start.yaml for the Istio deployment example
35+
sed -i.bak "/opa_container/{N;s/openpolicyagent\/opa:.*/openpolicyagent\/opa:$tag-istio\"\,/;}" examples/istio/quick_start.yaml && rm examples/istio/quick_start.yaml.bak
36+
sed -i.bak "s/image: openpolicyagent\/opa:.*/image: openpolicyagent\/opa:$tag/" examples/istio/quick_start.yaml && rm examples/istio/quick_start.yaml.bak
3437

3538
# update vendor
3639
env GO111MODULE=on go mod vendor

0 commit comments

Comments
 (0)