Skip to content

Commit

Permalink
Update to OPA v0.8.0
Browse files Browse the repository at this point in the history
Also, build.sh to set version and include the OPA version.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
  • Loading branch information
tsandall committed Apr 19, 2018
1 parent 3623937 commit 674d7f5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: all build

VERSION := 0.2.1
VERSION := 0.2.2

all: build

Expand Down
4 changes: 3 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ curl https://glide.sh/get | sh
echo "install all the dependencies"
glide install

OPA_VERSION=$(grep 'package: github.com/open-policy-agent/opa$' glide.yaml -A 1 | tail -n 1 | awk '{print $2}')

echo "build opa-docker-authz"
CGO_ENABLED=0 go build -ldflags "-X github.com/open-policy-agent/opa-docker-authz.Version=$VERSION" -o opa-docker-authz
CGO_ENABLED=0 go build -ldflags "-X github.com/open-policy-agent/opa-docker-authz/version.Version=$VERSION -X github.com/open-policy-agent/opa-docker-authz/version.OPAVersion=$OPA_VERSION" -o opa-docker-authz
2 changes: 1 addition & 1 deletion glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ import:
- package: github.com/fsnotify/fsnotify
version: 4da3e2cfbabc9f751898f250b49f2439785783a1
- package: github.com/open-policy-agent/opa
version: v0.6.0
version: v0.8.0
13 changes: 6 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import (
"os"

"github.com/docker/go-plugins-helpers/authorization"
"github.com/open-policy-agent/opa/rego"
version_pkg "github.com/open-policy-agent/opa-docker-authz/version"
"github.com/open-policy-agent/opa/ast"
"github.com/open-policy-agent/opa/loader"
"github.com/open-policy-agent/opa/rego"
)

// DockerAuthZPlugin implements the authorization.Plugin interface. Every
Expand Down Expand Up @@ -137,7 +138,7 @@ func regoSyntax(p string) int {

modules := map[string]*ast.Module{}

for _,m := range result.Modules {
for _, m := range result.Modules {
modules[m.Name] = m.Parsed
}

Expand All @@ -153,21 +154,19 @@ func regoSyntax(p string) int {
return 0
}

// Version is set by the build.
var Version = ""

func main() {

pluginName := flag.String("plugin-name", "opa-docker-authz", "sets the plugin name that will be registered with Docker")
allowPath := flag.String("allowPath", "data.docker.authz.allow", "sets the path of the allow decision in OPA")
policyFile := flag.String("policy-file", "policy.rego", "sets the path of the policy file to load")
version := flag.Bool("version", false, "print the version of the plugin")
check := flag.Bool("check", false , "checks the syntax of the policy-file")
check := flag.Bool("check", false, "checks the syntax of the policy-file")

flag.Parse()

if *version {
fmt.Println(Version)
fmt.Println("Version:", version_pkg.Version)
fmt.Println("OPA Version:", version_pkg.OPAVersion)
os.Exit(0)
}

Expand Down
11 changes: 11 additions & 0 deletions version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2018 The OPA Authors. All rights reserved.
// Use of this source code is governed by an Apache2
// license that can be found in the LICENSE file.

package version

// Version numbers set during build.
var (
Version = ""
OPAVersion = ""
)

0 comments on commit 674d7f5

Please sign in to comment.