This repository has been archived by the owner on Jun 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Nick Young <ynick@vmware.com>
- Loading branch information
Nick Young
committed
Nov 28, 2019
1 parent
1ec2fe5
commit afda097
Showing
5 changed files
with
620 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
language: go | ||
|
||
go: | ||
- 1.13.x | ||
|
||
sudo: false | ||
|
||
cache: | ||
directories: | ||
- /home/travis/.cache/go-build | ||
- /home/travis/gopath/pkg/mod | ||
|
||
env: | ||
- GOPROXY=https://proxy.golang.org/ | ||
|
||
script: | ||
- make check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
ORG = projectcontour | ||
PROJECT = ir2proxy | ||
MODULE = github.com/$(ORG)/$(PROJECT) | ||
REGISTRY ?= projectcontour | ||
IMAGE := $(REGISTRY)/$(PROJECT) | ||
SRCDIRS := ./cmd | ||
|
||
TAG_LATEST ?= false | ||
|
||
# Sets GIT_REF to a tag if it's present, otherwise the short rev. | ||
GIT_REF = $(shell git describe --tags || git rev-parse --short=8 --verify HEAD) | ||
VERSION ?= $(GIT_REF) | ||
# Used for the tag-latest action. | ||
# The tag-latest action will be a noop unless this is explicitly | ||
# set outside this Makefile, as a safety valve. | ||
LATEST_VERSION ?= NOLATEST | ||
|
||
export GO111MODULE=on | ||
|
||
Check_Targets := \ | ||
check-test \ | ||
check-test-race \ | ||
check-vet \ | ||
check-gofmt \ | ||
check-staticcheck \ | ||
check-misspell \ | ||
check-unconvert \ | ||
check-unparam \ | ||
check-ineffassign \ | ||
|
||
.PHONY: check | ||
check: install $(Check_Targets) ## Run tests and CI checks | ||
|
||
.PHONY: pedantic | ||
pedantic: check check-errcheck ## Run pedantic CI checks | ||
|
||
install: ## Build and install the contour binary | ||
go install -mod=readonly -v -tags "oidc gcp" $(MODULE)/cmd/$(PROJECT) | ||
|
||
race: | ||
go install -mod=readonly -v -race -tags "oidc gcp" $(MODULE)/cmd/$(PROJECT) | ||
|
||
download: ## Download Go modules | ||
go mod download | ||
|
||
.PHONY: check-test | ||
check-test: | ||
go test -cover -mod=readonly $(MODULE)/... | ||
|
||
.PHONY: check-test-race | ||
check-test-race: | check-test | ||
go test -race -mod=readonly $(MODULE)/... | ||
|
||
.PHONY: check-staticcheck | ||
check-staticcheck: | ||
go install honnef.co/go/tools/cmd/staticcheck | ||
staticcheck \ | ||
-checks all,-ST1003 \ | ||
$(MODULE)/{cmd,internal}/... | ||
|
||
.PHONY: check-misspell | ||
check-misspell: | ||
go install github.com/client9/misspell/cmd/misspell | ||
misspell \ | ||
-i clas \ | ||
-locale US \ | ||
-error \ | ||
cmd/* internal/* docs/* design/* site/*.md site/_{guides,posts,resources} *.md | ||
|
||
.PHONY: check-unconvert | ||
check-unconvert: | ||
go install github.com/mdempsky/unconvert | ||
unconvert -v $(MODULE)/{cmd,internal}/... | ||
|
||
.PHONY: check-ineffassign | ||
check-ineffassign: | ||
go install github.com/gordonklaus/ineffassign | ||
find $(SRCDIRS) -name '*.go' | xargs ineffassign | ||
|
||
.PHONY: check-unparam | ||
check-unparam: | ||
go install mvdan.cc/unparam | ||
unparam -exported $(MODULE)/{cmd,internal}/... | ||
|
||
.PHONY: check-errcheck | ||
check-errcheck: | ||
go install github.com/kisielk/errcheck | ||
errcheck $(MODULE)/... | ||
|
||
.PHONY: check-gofmt | ||
check-gofmt: | ||
@echo Checking code is gofmted | ||
@test -z "$(shell gofmt -s -l -d -e $(SRCDIRS) | tee /dev/stderr)" | ||
|
||
.PHONY: check-vet | ||
check-vet: | check-test | ||
go vet $(MODULE)/... | ||
|
||
help: ## Display this help | ||
@echo Contour high performance Ingress controller for Kubernetes | ||
@echo | ||
@echo Targets: | ||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9._-]+:.*?## / {printf " %-20s %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package main | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
|
||
irv1beta1 "github.com/projectcontour/contour/apis/contour/v1beta1" | ||
contourscheme "github.com/projectcontour/contour/apis/generated/clientset/versioned/scheme" | ||
"github.com/sirupsen/logrus" | ||
kingpin "gopkg.in/alecthomas/kingpin.v2" | ||
"k8s.io/client-go/kubernetes/scheme" | ||
) | ||
|
||
func main() { | ||
log := logrus.StandardLogger() | ||
app := kingpin.New("ir2proxy", "Contour IngressRoute to HTTPPRoxy conversion tool.") | ||
|
||
yamlfile := app.Arg("yaml", "YAML file to parse for IngressRoute objects").Required().String() | ||
|
||
args := os.Args[1:] | ||
//kingpin.MustParse(app.Parse(args)) | ||
app.Parse(args) | ||
|
||
if *yamlfile == "" { | ||
app.FatalUsage("Need a YAML file to operate on.") | ||
} | ||
|
||
if !verifyYAMLFile(*yamlfile) { | ||
log.Fatalf("File %s does not exist", *yamlfile) | ||
} | ||
|
||
data, err := ioutil.ReadFile(*yamlfile) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
contourscheme.AddToScheme(scheme.Scheme) | ||
|
||
decode := scheme.Codecs.UniversalDeserializer().Decode | ||
|
||
ir, groupVersionKind, err := decode(data, nil, nil) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
switch t := ir.(type) { | ||
case *irv1beta1.IngressRoute: | ||
log.Info("This was an IngressRoute") | ||
//log.Infof("%#v", t) | ||
log.Infof("IngressRoute %s, namespace %s", t.ObjectMeta.Name, t.ObjectMeta.Namespace) | ||
default: | ||
log.Infof("This utility only works with IngressRoute, a %s was supplied.", groupVersionKind) | ||
} | ||
|
||
} | ||
|
||
func verifyYAMLFile(filename string) bool { | ||
info, err := os.Stat(filename) | ||
if os.IsNotExist(err) { | ||
return false | ||
} | ||
return !info.IsDir() | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module github.com/projectcontour/ir2proxy | ||
|
||
go 1.13 | ||
|
||
require ( | ||
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d // indirect | ||
github.com/projectcontour/contour v1.0.0 | ||
github.com/sirupsen/logrus v1.4.2 | ||
gopkg.in/alecthomas/kingpin.v2 v2.2.6 | ||
k8s.io/client-go v0.0.0-20190918200256-06eb1244587a | ||
) |
Oops, something went wrong.