This repository has been archived by the owner on Dec 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5c2a7ea
Showing
118 changed files
with
31,353 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 @@ | ||
config/kubernetes/*/secrets/*.yaml |
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,12 @@ | ||
FROM golang:alpine AS build | ||
|
||
WORKDIR /go/src/github.com/urcomputeringpal/kubevalidator | ||
COPY ./vendor ./vendor | ||
RUN go install -v ./vendor/... | ||
COPY . . | ||
RUN go install -v github.com/urcomputeringpal/kubevalidator | ||
|
||
|
||
FROM alpine | ||
COPY --from=build /go/bin/kubevalidator /go/bin/kubevalidator | ||
ENTRYPOINT ["/go/bin/kubevalidator"] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,41 @@ | ||
# Gopkg.toml example | ||
# | ||
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md | ||
# for detailed Gopkg.toml documentation. | ||
# | ||
# required = ["github.com/user/thing/cmd/thing"] | ||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project" | ||
# version = "1.0.0" | ||
# | ||
# [[constraint]] | ||
# name = "github.com/user/project2" | ||
# branch = "dev" | ||
# source = "github.com/myfork/project2" | ||
# | ||
# [[override]] | ||
# name = "github.com/x/y" | ||
# version = "2.4.0" | ||
|
||
[prune] | ||
go-tests = true | ||
non-go = true | ||
unused-packages = true | ||
|
||
[[override]] | ||
name = "k8s.io/client-go" | ||
version = "~7.0" | ||
|
||
[[override]] | ||
name = "k8s.io/apimachinery" | ||
version = "kubernetes-1.10.0" | ||
|
||
[[constraint]] | ||
branch = "master" | ||
name = "github.com/google/go-github" | ||
|
||
[[constraint]] | ||
name = "github.com/bradleyfalzon/ghinstallation" | ||
version = "0.1.2" |
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 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: kubevalidator | ||
namespace: kubevalidator | ||
data: | ||
# See https://github.com/milesp20/intel_nuc_led#usage | ||
NUC_LED_READY: ring,09,none,green | ||
NUC_LED_UNSCHEDULABLE: ring,50,fade_slow,yellow | ||
NUC_LED_NOT_READY: ring,100,fade_slow,red | ||
NUC_LED_ERROR: ring,100,blink_fast,red |
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,23 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: kubevalidator | ||
namespace: kubevalidator | ||
spec: | ||
replicas: 2 | ||
selector: | ||
matchLabels: | ||
app: kubevalidator | ||
template: | ||
metadata: | ||
labels: | ||
app: kubevalidator | ||
spec: | ||
containers: | ||
- name: kubevalidator | ||
image: gcr.io/rancho-de-newland/kubevalidator | ||
envFrom: | ||
- configMapRef: | ||
name: kubevalidator | ||
- secretRef: | ||
name: kubevalidator |
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,23 @@ | ||
apiVersion: extensions/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
annotations: | ||
ingress.kubernetes.io/enable-cors: "true" | ||
ingress.kubernetes.io/ssl-redirect: "true" | ||
kubernetes.io/ingress.class: nginx | ||
kubernetes.io/tls-acme: "true" | ||
name: kubevalidator | ||
namespace: kubevalidator | ||
spec: | ||
rules: | ||
- host: kubevalidator.k.jnewland.com | ||
http: | ||
paths: | ||
- backend: | ||
serviceName: kubevalidator | ||
servicePort: 8080 | ||
path: / | ||
tls: | ||
- hosts: | ||
- kubevalidator.k.jnewland.com | ||
secretName: kubevalidator-tls |
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 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: kubevalidator | ||
namespace: kubevalidator | ||
spec: | ||
ports: | ||
- name: ui | ||
port: 8080 | ||
selector: | ||
app: kubevalidator |
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,111 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"fmt" | ||
"log" | ||
"net/http" | ||
"os" | ||
"os/signal" | ||
"syscall" | ||
|
||
"github.com/bradleyfalzon/ghinstallation" | ||
"github.com/google/go-github/github" | ||
) | ||
|
||
type kubevalidator struct { | ||
Port int | ||
WebhookSecretKey string | ||
GitHubAppKeyFile string | ||
GitHubAppID int | ||
GitHubAppClient *github.Client | ||
tr http.RoundTripper | ||
ctx *context.Context | ||
} | ||
|
||
func (kv *kubevalidator) handle(w http.ResponseWriter, r *http.Request) { | ||
payload, err := github.ValidatePayload(r, []byte(kv.WebhookSecretKey)) | ||
if err != nil { | ||
log.Println(err) | ||
return | ||
} | ||
defer r.Body.Close() | ||
|
||
event, err := github.ParseWebHook(github.WebHookType(r), payload) | ||
if err != nil { | ||
log.Println(err) | ||
return | ||
} | ||
|
||
switch e := event.(type) { | ||
case *github.CheckSuiteEvent: | ||
log.Printf("received %s\n", event) | ||
return | ||
default: | ||
log.Printf("ignoring %s\n", e) | ||
return | ||
} | ||
} | ||
|
||
func (kv *kubevalidator) health(w http.ResponseWriter, r *http.Request) { | ||
fmt.Fprintf(w, "cool") | ||
} | ||
|
||
func runWithContext(ctx context.Context) error { | ||
kv := kubevalidator{} | ||
flag.IntVar(&kv.Port, "port", 8080, "port to listen on") | ||
flag.StringVar(&kv.WebhookSecretKey, "webhook-secret", "", "webhook secret") | ||
flag.StringVar(&kv.GitHubAppKeyFile, "github-app-key-file", "", "path to key file") | ||
flag.IntVar(&kv.GitHubAppID, "github-app-id", -1, "app ID") | ||
flag.Parse() | ||
if len(flag.Args()) > 0 { | ||
fmt.Printf("Unparsed arguments provided:\n\n%+v\n\n", flag.Args()) | ||
flag.Usage() | ||
os.Exit(2) | ||
} | ||
|
||
itr, err := ghinstallation.NewAppsTransportKeyFromFile(kv.tr, kv.GitHubAppID, kv.GitHubAppKeyFile) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
kv.ctx = &ctx | ||
kv.tr = http.DefaultTransport | ||
kv.GitHubAppClient = github.NewClient(&http.Client{Transport: itr}) | ||
|
||
http.HandleFunc("/webhook", kv.handle) | ||
http.HandleFunc("/health", kv.health) | ||
log.Println("hi") | ||
return http.ListenAndServe(fmt.Sprintf(":%d", kv.Port), nil) | ||
} | ||
|
||
func cancelOnInterrupt(ctx context.Context, f context.CancelFunc) { | ||
term := make(chan os.Signal) | ||
signal.Notify(term, os.Interrupt, syscall.SIGTERM) | ||
|
||
for { | ||
select { | ||
case <-term: | ||
log.Println("Received SIGTERM, exiting gracefully...") | ||
f() | ||
os.Exit(0) | ||
case <-ctx.Done(): | ||
os.Exit(0) | ||
} | ||
} | ||
} | ||
|
||
func run() error { | ||
ctx, cancelFunc := context.WithCancel(context.Background()) | ||
defer cancelFunc() | ||
go cancelOnInterrupt(ctx, cancelFunc) | ||
|
||
return runWithContext(ctx) | ||
} | ||
|
||
func main() { | ||
if err := run(); err != nil && err != context.Canceled && err != context.DeadlineExceeded { | ||
panic(err) | ||
} | ||
} |
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,9 @@ | ||
apiVersion: skaffold/v1alpha2 | ||
kind: Config | ||
build: | ||
artifacts: | ||
- imageName: gcr.io/rancho-de-newland/kubevalidator | ||
deploy: | ||
kubectl: | ||
manifests: | ||
- config/kubernetes/default/**/*.yaml |
24 changes: 24 additions & 0 deletions
24
vendor/github.com/bradleyfalzon/ghinstallation/LICENSE
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
vendor/github.com/bradleyfalzon/ghinstallation/appsTransport.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.