diff --git a/Makefile b/Makefile index a713ba5..feb0ed2 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,10 @@ all: build ENVVAR = GOOS=linux GOARCH=amd64 -TAG = v0.1.6 +TAG = v0.1.7 APP_NAME = calico-accountant +REPO = andreas-p +IMAGE_TAG = $(REPO)/$(APP_NAME):$(TAG) clean: rm -f $(APP_NAME) @@ -19,6 +21,10 @@ test-unit: clean fmt build # Make the container using docker multi-stage build process # So you don't necessarily have to install golang to make the container container: - docker build -f Dockerfile -t monzo/$(APP_NAME):$(TAG) . + docker build -f Dockerfile -t $(IMAGE_TAG) . + + +binary: container + docker run --rm $(IMAGE_TAG) cat /calico-accountant >$(APP_NAME) .PHONY: all clean fmt build container diff --git a/vendor/github.com/coreos/etcd/cmd/etcd b/vendor/github.com/coreos/etcd/cmd/etcd index b870225..a96aa0e 120000 --- a/vendor/github.com/coreos/etcd/cmd/etcd +++ b/vendor/github.com/coreos/etcd/cmd/etcd @@ -1 +1 @@ -../ \ No newline at end of file +.. \ No newline at end of file diff --git a/vendor/github.com/projectcalico/libcalico-go/lib/backend/syncersv1/updateprocessors/rules.go b/vendor/github.com/projectcalico/libcalico-go/lib/backend/syncersv1/updateprocessors/rules.go index c09a1c8..d7e6dc8 100644 --- a/vendor/github.com/projectcalico/libcalico-go/lib/backend/syncersv1/updateprocessors/rules.go +++ b/vendor/github.com/projectcalico/libcalico-go/lib/backend/syncersv1/updateprocessors/rules.go @@ -55,6 +55,7 @@ func entityRuleAPIV2TOBackend(er *apiv3.EntityRule, ns string) (nsSelector, sele // all endpoints, translate this to an equivalent expressions which means select any workload that // is in a namespace. nsSelector = strings.Replace(nsSelector, "all()", "has(projectcalico.org/namespace)", -1) + nsSelector = strings.Replace(nsSelector, "global()", "!has(projectcalico.org/namespace)", -1) } else if ns != "" { // No namespace selector was given and this is a namespaced network policy, // so the rule applies only to its own namespace. diff --git a/vendor/github.com/projectcalico/libcalico-go/lib/selector/parser/ast.go b/vendor/github.com/projectcalico/libcalico-go/lib/selector/parser/ast.go index f729e28..0945db6 100644 --- a/vendor/github.com/projectcalico/libcalico-go/lib/selector/parser/ast.go +++ b/vendor/github.com/projectcalico/libcalico-go/lib/selector/parser/ast.go @@ -429,3 +429,19 @@ func appendLabelOpAndQuotedString(fragments []string, label, op, s string) []str } return append(fragments, label, op, quote, s, quote) } + +type GlobalNode struct { +} + +func (node *GlobalNode) Evaluate(labels Labels) bool { + + return true +} + +func (node *GlobalNode) AcceptVisitor(v Visitor) { + v.Visit(node) +} + +func (node *GlobalNode) collectFragments(fragments []string) []string { + return append(fragments, "global()") +} \ No newline at end of file diff --git a/vendor/github.com/projectcalico/libcalico-go/lib/selector/parser/parser.go b/vendor/github.com/projectcalico/libcalico-go/lib/selector/parser/parser.go index bca901b..a754395 100644 --- a/vendor/github.com/projectcalico/libcalico-go/lib/selector/parser/parser.go +++ b/vendor/github.com/projectcalico/libcalico-go/lib/selector/parser/parser.go @@ -146,6 +146,9 @@ func parseOperation(tokens []tokenizer.Token) (sel node, remTokens []tokenizer.T case tokenizer.TokAll: sel = &AllNode{} remTokens = tokens[1:] + case tokenizer.TokGlobal: + sel = &GlobalNode{} + remTokens = tokens[1:] case tokenizer.TokLabel: // should have an operator and a literal. if len(tokens) < 3 { diff --git a/vendor/github.com/projectcalico/libcalico-go/lib/selector/tokenizer/tokenizer.go b/vendor/github.com/projectcalico/libcalico-go/lib/selector/tokenizer/tokenizer.go index f4ec232..bb34c72 100644 --- a/vendor/github.com/projectcalico/libcalico-go/lib/selector/tokenizer/tokenizer.go +++ b/vendor/github.com/projectcalico/libcalico-go/lib/selector/tokenizer/tokenizer.go @@ -41,6 +41,7 @@ const ( TokStartsWith TokEndsWith TokAll + TokGlobal TokHas TokLParen TokRParen @@ -64,6 +65,7 @@ const ( LabelKeyMatcher = `[a-zA-Z0-9_./-]{1,512}` hasExpr = `has\(\s*(` + LabelKeyMatcher + `)\s*\)` allExpr = `all\(\s*\)` + globalExpr = `global\(\s*\)` notInExpr = `not\s*in\b` inExpr = `in\b` ) @@ -75,6 +77,7 @@ var ( endsWithRegex = regexp.MustCompile(`^ends\s*with`) hasRegex = regexp.MustCompile("^" + hasExpr) allRegex = regexp.MustCompile("^" + allExpr) + globalRegex = regexp.MustCompile("^" + globalExpr) notInRegex = regexp.MustCompile("^" + notInExpr) inRegex = regexp.MustCompile("^" + inExpr) ) @@ -199,6 +202,10 @@ func Tokenize(input string) (tokens []Token, err error) { // Found "all" tokens = append(tokens, Token{TokAll, nil}) input = input[idxs[1]:] + } else if idxs := globalRegex.FindStringIndex(input); idxs != nil { + // Found "global" + tokens = append(tokens, Token{TokGlobal, nil}) + input = input[idxs[1]:] } else if idxs := identifierRegex.FindStringIndex(input); idxs != nil { // Found "label" endIndex := idxs[1]