Permalink
Browse files

greetings

  • Loading branch information...
jnewland committed Aug 4, 2018
0 parents commit 5c2a7ea76a8db7fc8a4461805785bf0f27c28d9e
Showing with 31,353 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +12 −0 Dockerfile
  3. +33 −0 Gopkg.lock
  4. +41 −0 Gopkg.toml
  5. +11 −0 config/kubernetes/default/configmaps/kubevalidator.yaml
  6. +23 −0 config/kubernetes/default/deployments/kubevalidator.yaml
  7. +23 −0 config/kubernetes/default/ingresses/kubevalidator.yaml
  8. +11 −0 config/kubernetes/default/services/kubevalidator.yaml
  9. +111 −0 main.go
  10. +9 −0 skaffold.yaml
  11. +24 −0 vendor/github.com/bradleyfalzon/ghinstallation/LICENSE
  12. +80 −0 vendor/github.com/bradleyfalzon/ghinstallation/appsTransport.go
  13. +136 −0 vendor/github.com/bradleyfalzon/ghinstallation/transport.go
  14. +8 −0 vendor/github.com/dgrijalva/jwt-go/LICENSE
  15. +134 −0 vendor/github.com/dgrijalva/jwt-go/claims.go
  16. +4 −0 vendor/github.com/dgrijalva/jwt-go/doc.go
  17. +148 −0 vendor/github.com/dgrijalva/jwt-go/ecdsa.go
  18. +67 −0 vendor/github.com/dgrijalva/jwt-go/ecdsa_utils.go
  19. +59 −0 vendor/github.com/dgrijalva/jwt-go/errors.go
  20. +95 −0 vendor/github.com/dgrijalva/jwt-go/hmac.go
  21. +94 −0 vendor/github.com/dgrijalva/jwt-go/map_claims.go
  22. +52 −0 vendor/github.com/dgrijalva/jwt-go/none.go
  23. +148 −0 vendor/github.com/dgrijalva/jwt-go/parser.go
  24. +101 −0 vendor/github.com/dgrijalva/jwt-go/rsa.go
  25. +126 −0 vendor/github.com/dgrijalva/jwt-go/rsa_pss.go
  26. +101 −0 vendor/github.com/dgrijalva/jwt-go/rsa_utils.go
  27. +35 −0 vendor/github.com/dgrijalva/jwt-go/signing_method.go
  28. +108 −0 vendor/github.com/dgrijalva/jwt-go/token.go
  29. +174 −0 vendor/github.com/google/go-github/AUTHORS
  30. +27 −0 vendor/github.com/google/go-github/LICENSE
  31. +69 −0 vendor/github.com/google/go-github/github/activity.go
  32. +328 −0 vendor/github.com/google/go-github/github/activity_events.go
  33. +223 −0 vendor/github.com/google/go-github/github/activity_notifications.go
  34. +135 −0 vendor/github.com/google/go-github/github/activity_star.go
  35. +146 −0 vendor/github.com/google/go-github/github/activity_watching.go
  36. +101 −0 vendor/github.com/google/go-github/github/admin.go
  37. +171 −0 vendor/github.com/google/go-github/github/admin_stats.go
  38. +222 −0 vendor/github.com/google/go-github/github/apps.go
  39. +101 −0 vendor/github.com/google/go-github/github/apps_installation.go
  40. +168 −0 vendor/github.com/google/go-github/github/apps_marketplace.go
  41. +435 −0 vendor/github.com/google/go-github/github/authorizations.go
  42. +428 −0 vendor/github.com/google/go-github/github/checks.go
  43. +187 −0 vendor/github.com/google/go-github/github/doc.go
  44. +785 −0 vendor/github.com/google/go-github/github/event_types.go
  45. +332 −0 vendor/github.com/google/go-github/github/gen-accessors.go
  46. +388 −0 vendor/github.com/google/go-github/github/gists.go
  47. +119 −0 vendor/github.com/google/go-github/github/gists_comments.go
  48. +12 −0 vendor/github.com/google/go-github/github/git.go
  49. +75 −0 vendor/github.com/google/go-github/github/git_blobs.go
  50. +139 −0 vendor/github.com/google/go-github/github/git_commits.go
  51. +233 −0 vendor/github.com/google/go-github/github/git_refs.go
  52. +84 −0 vendor/github.com/google/go-github/github/git_tags.go
  53. +99 −0 vendor/github.com/google/go-github/github/git_trees.go
  54. +11,789 −0 vendor/github.com/google/go-github/github/github-accessors.go
  55. +991 −0 vendor/github.com/google/go-github/github/github.go
  56. +64 −0 vendor/github.com/google/go-github/github/gitignore.go
  57. +332 −0 vendor/github.com/google/go-github/github/issues.go
  58. +85 −0 vendor/github.com/google/go-github/github/issues_assignees.go
  59. +152 −0 vendor/github.com/google/go-github/github/issues_comments.go
  60. +151 −0 vendor/github.com/google/go-github/github/issues_events.go
  61. +270 −0 vendor/github.com/google/go-github/github/issues_labels.go
  62. +160 −0 vendor/github.com/google/go-github/github/issues_milestones.go
  63. +149 −0 vendor/github.com/google/go-github/github/issues_timeline.go
  64. +97 −0 vendor/github.com/google/go-github/github/licenses.go
  65. +247 −0 vendor/github.com/google/go-github/github/messages.go
  66. +224 −0 vendor/github.com/google/go-github/github/migrations.go
  67. +329 −0 vendor/github.com/google/go-github/github/migrations_source_import.go
  68. +214 −0 vendor/github.com/google/go-github/github/migrations_user.go
  69. +257 −0 vendor/github.com/google/go-github/github/misc.go
  70. +212 −0 vendor/github.com/google/go-github/github/orgs.go
  71. +107 −0 vendor/github.com/google/go-github/github/orgs_hooks.go
  72. +370 −0 vendor/github.com/google/go-github/github/orgs_members.go
  73. +81 −0 vendor/github.com/google/go-github/github/orgs_outside_collaborators.go
  74. +60 −0 vendor/github.com/google/go-github/github/orgs_projects.go
  75. +514 −0 vendor/github.com/google/go-github/github/orgs_teams.go
  76. +91 −0 vendor/github.com/google/go-github/github/orgs_users_blocking.go
  77. +459 −0 vendor/github.com/google/go-github/github/projects.go
  78. +380 −0 vendor/github.com/google/go-github/github/pulls.go
  79. +188 −0 vendor/github.com/google/go-github/github/pulls_comments.go
  80. +79 −0 vendor/github.com/google/go-github/github/pulls_reviewers.go
  81. +236 −0 vendor/github.com/google/go-github/github/pulls_reviews.go
  82. +283 −0 vendor/github.com/google/go-github/github/reactions.go
  83. +1,072 −0 vendor/github.com/google/go-github/github/repos.go
  84. +140 −0 vendor/github.com/google/go-github/github/repos_collaborators.go
  85. +161 −0 vendor/github.com/google/go-github/github/repos_comments.go
  86. +237 −0 vendor/github.com/google/go-github/github/repos_commits.go
  87. +59 −0 vendor/github.com/google/go-github/github/repos_community_health.go
  88. +266 −0 vendor/github.com/google/go-github/github/repos_contents.go
  89. +237 −0 vendor/github.com/google/go-github/github/repos_deployments.go
  90. +89 −0 vendor/github.com/google/go-github/github/repos_forks.go
  91. +200 −0 vendor/github.com/google/go-github/github/repos_hooks.go
  92. +98 −0 vendor/github.com/google/go-github/github/repos_invitations.go
  93. +111 −0 vendor/github.com/google/go-github/github/repos_keys.go
  94. +38 −0 vendor/github.com/google/go-github/github/repos_merging.go
  95. +143 −0 vendor/github.com/google/go-github/github/repos_pages.go
  96. +110 −0 vendor/github.com/google/go-github/github/repos_prereceive_hooks.go
  97. +72 −0 vendor/github.com/google/go-github/github/repos_projects.go
  98. +353 −0 vendor/github.com/google/go-github/github/repos_releases.go
  99. +226 −0 vendor/github.com/google/go-github/github/repos_stats.go
  100. +129 −0 vendor/github.com/google/go-github/github/repos_statuses.go
  101. +141 −0 vendor/github.com/google/go-github/github/repos_traffic.go
  102. +255 −0 vendor/github.com/google/go-github/github/search.go
  103. +93 −0 vendor/github.com/google/go-github/github/strings.go
  104. +7 −0 vendor/github.com/google/go-github/github/teams.go
  105. +154 −0 vendor/github.com/google/go-github/github/teams_discussion_comments.go
  106. +159 −0 vendor/github.com/google/go-github/github/teams_discussions.go
  107. +41 −0 vendor/github.com/google/go-github/github/timestamp.go
  108. +233 −0 vendor/github.com/google/go-github/github/users.go
  109. +67 −0 vendor/github.com/google/go-github/github/users_administration.go
  110. +91 −0 vendor/github.com/google/go-github/github/users_blocking.go
  111. +71 −0 vendor/github.com/google/go-github/github/users_emails.go
  112. +119 −0 vendor/github.com/google/go-github/github/users_followers.go
  113. +140 −0 vendor/github.com/google/go-github/github/users_gpg_keys.go
  114. +108 −0 vendor/github.com/google/go-github/github/users_keys.go
  115. +20 −0 vendor/github.com/google/go-github/github/with_appengine.go
  116. +19 −0 vendor/github.com/google/go-github/github/without_appengine.go
  117. +27 −0 vendor/github.com/google/go-querystring/LICENSE
  118. +320 −0 vendor/github.com/google/go-querystring/query/encode.go
@@ -0,0 +1 @@
config/kubernetes/*/secrets/*.yaml
@@ -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.

Oops, something went wrong.
@@ -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"
@@ -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
@@ -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
@@ -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
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: kubevalidator
namespace: kubevalidator
spec:
ports:
- name: ui
port: 8080
selector:
app: kubevalidator
111 main.go
@@ -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)
}
}
@@ -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

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 5c2a7ea

Please sign in to comment.