forked from CATechnologiesTest/kubeiql
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
13 changed files
with
811 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,9 @@ | ||
FROM isl-dsdc.ca.com:5000/ca-standard-images/alpine34:latest | ||
USER 496 | ||
ADD ./auth /auth | ||
ADD ./*.crt / | ||
EXPOSE 8128 | ||
|
||
CMD ["/auth"] | ||
|
||
|
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,33 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
type deployment struct { | ||
Id string | ||
Metadata *metadata | ||
Owner *resource | ||
RootOwner *resource | ||
} | ||
|
||
type deploymentResolver struct { | ||
ctx context.Context | ||
d *deployment | ||
} | ||
|
||
func (r *deploymentResolver) Id() string { | ||
return r.d.Id | ||
} | ||
|
||
func (r *deploymentResolver) Metadata() *metadataResolver { | ||
return &metadataResolver{r.ctx, r.d.Metadata} | ||
} | ||
|
||
func (r *deploymentResolver) Owner() *resourceResolver { | ||
return &resourceResolver{r.ctx, r.d.Owner} | ||
} | ||
|
||
func (r *deploymentResolver) RootOwner() *resourceResolver { | ||
return &resourceResolver{r.ctx, r.d.RootOwner} | ||
} |
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,15 @@ | ||
#!/bin/bash | ||
|
||
go get -u github.com/kardianos/govendor | ||
$GOPATH/bin/govendor sync | ||
CGO_ENABLED=0 go build -a -v -ldflags '-s' | ||
#go build | ||
# # Run unit tests and generate code coverage reports -- an html one | ||
# # for local viewing and a cobertura one for jenkins builds. | ||
#go get -u github.com/t-yuki/gocover-cobertura | ||
# go test -coverprofile coverage.txt | ||
# result=$? | ||
# go tool cover -html=coverage.txt -o coverage.html | ||
# $GOPATH/bin/gocover-cobertura < coverage.txt > coverage.xml | ||
exit $result | ||
|
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,15 @@ | ||
#!/bin/bash | ||
# | ||
# In Jenkins, make a free-form job that exports the following env vars | ||
# prior to invoking this script: | ||
# | ||
# THIS_CONTAINER=<name of the container for jenkins itself> | ||
# WORKSPACE=<jenkins workspace for the build> | ||
# PROJDIR=<location of go sources for the project, e.g., $WORKSPACE/src/auth | ||
# PG_NAME=<name for the postgres DB container used by this job> | ||
# | ||
docker run -d --name $PG_NAME postgres:9.5.5-alpine | ||
docker run --rm --link $PG_NAME:db --volumes-from=$THIS_CONTAINER yipee-tools-spoke-cos.ca.com:5000/yipee-go-builder bash -c "export GOPATH=$WORKSPACE; export POSTGRES_HOST=db; export POSTGRES_DB=postgres export POSTGRES_USER=postgres; export YIPEE_TEAM_OWNER=jenkinsbuild; cd $PROJDIR; bash -x ./gobuild.sh" | ||
rc=$? | ||
docker rm -fv $PG_NAME | ||
exit $rc |
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,183 @@ | ||
package main | ||
|
||
import ( | ||
// "bytes" | ||
"context" | ||
// "crypto/tls" | ||
// "crypto/x509" | ||
// "database/sql" | ||
// "encoding/json" | ||
// "errors" | ||
// "fmt" | ||
// log "github.com/Sirupsen/logrus" | ||
// "github.com/jackc/pgx" | ||
// "github.com/jackc/pgx/stdlib" | ||
// "io/ioutil" | ||
// "math" | ||
// "os" | ||
// "runtime" | ||
// "strconv" | ||
// "strings" | ||
// "sync" | ||
// "time" | ||
) | ||
|
||
// The schema below defines the objects and relationships that can be | ||
// queried and modified. Each "type" below can be returned from | ||
// queries so a "resolver" must be implemented. The resolver has a | ||
// method for each field of the object and the graphql server calls a | ||
// resolver method as needed based on what is requested by the | ||
// user. Each type has a struct that holds its scalar values while set | ||
// or list values are constructed on demand. Each "input" below | ||
// represents an argument to a query rather than a returnable | ||
// Ids are represented by the String type (which is convertible | ||
// to/from string). This is the type the graphql server expects. | ||
|
||
var Schema = ` | ||
schema { | ||
query: Query | ||
mutation: Mutation | ||
} | ||
# The query type, represents all of the entry points into our object graph | ||
type Query { | ||
# look up pods | ||
allPods(): [Pod] | ||
podById(id: String!): Pod | ||
# look up deployments | ||
allDeployments(): [Deployment] | ||
deploymentById(id: String!): Deployment | ||
# look up replica sets | ||
allReplicaSets(): [ReplicaSet] | ||
replicaSetById(id: String!): ReplicaSet | ||
} | ||
# The mutation type, represents all updates we can make to our data | ||
type Mutation { | ||
} | ||
# Available logging levels | ||
enum LogLevel { | ||
debug | ||
info | ||
warning | ||
error | ||
fatal | ||
panic | ||
} | ||
# A pod | ||
type Pod { | ||
# The ID of the pod | ||
id: String! | ||
# The metadata for the pod (name, labels, namespace, etc.) | ||
metadata: Metadata! | ||
# The direct owner of the pod | ||
owner: Resource | ||
# The root owner of the pod | ||
rootOwner: Resource | ||
} | ||
# A replicaSet | ||
type ReplicaSet { | ||
# The ID of the replicaSet | ||
id: String! | ||
# The metadata for the replicaSet (name, labels, namespace, etc.) | ||
metadata: Metadata! | ||
# The direct owner of the replicaSet | ||
owner: Resource | ||
# The root owner of the replicaSet | ||
rootOwner: Resource | ||
} | ||
# A deployment | ||
type Deployment { | ||
# The ID of the deployment | ||
id: String! | ||
# The metadata for the deployment (name, labels, namespace, etc.) | ||
metadata: Metadata! | ||
# The direct owner of the deployment | ||
owner: Resource | ||
# The root owner of the deployment | ||
rootOwner: Resource | ||
} | ||
# metadata | ||
type Metadata { | ||
# When was the decorated object created | ||
creationTimestamp: String | ||
# Prefix for generated names | ||
generateName: String! | ||
# Top level labels | ||
labels: [Label!]! | ||
# Generated name | ||
name: String! | ||
# Namespace containing the object | ||
namespace: String! | ||
# All owners | ||
ownerReferences: [Resource!]! | ||
# Version | ||
resourceVersion: String! | ||
# How to find this object | ||
selfLink: String! | ||
# UUID | ||
uid: String! | ||
} | ||
# A label | ||
type Label { | ||
# label name | ||
name: String! | ||
# label value | ||
value: String! | ||
} | ||
# Any Kubernetes resource | ||
interface Resource { | ||
# resource id | ||
id: String! | ||
# resource metadata | ||
metadata: Metadata! | ||
# resource direct owner | ||
owner: Resource | ||
# resource root owner | ||
rootOwner: Resource | ||
} | ||
` | ||
|
||
// The root of all queries and mutations. All defined queries and mutations | ||
// start as methods on Resolver | ||
type Resolver struct { | ||
} | ||
|
||
func (r *Resolver) AllPods(ctx context.Context) *[]*podResolver { | ||
var podResolvers []*podResolver | ||
return &podResolvers | ||
} | ||
|
||
func (r *Resolver) PodById( | ||
ctx context.Context, | ||
args *struct{ ID string }) *podResolver { | ||
return nil | ||
} | ||
|
||
func (r *Resolver) AllDeployments(ctx context.Context) *[]*deploymentResolver { | ||
var deploymentResolvers []*deploymentResolver | ||
return &deploymentResolvers | ||
} | ||
|
||
func (r *Resolver) DeploymentById( | ||
ctx context.Context, | ||
args *struct{ ID string }) *deploymentResolver { | ||
return nil | ||
} | ||
|
||
func (r *Resolver) AllReplicaSets(ctx context.Context) *[]*replicaSetResolver { | ||
var replicaSetResolvers []*replicaSetResolver | ||
return &replicaSetResolvers | ||
} | ||
|
||
func (r *Resolver) ReplicaSetById( | ||
ctx context.Context, | ||
args *struct{ ID string }) *replicaSetResolver { | ||
return nil | ||
} |
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 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
type label struct { | ||
Name string | ||
Value string | ||
} | ||
|
||
type labelResolver struct { | ||
ctx context.Context | ||
l *label | ||
} | ||
|
||
func (r *labelResolver) Name() string { | ||
return r.l.Name | ||
} | ||
|
||
func (r *labelResolver) Value() string { | ||
return r.l.Value | ||
} |
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,19 @@ | ||
#!/bin/bash | ||
REGISTRY=yipee-development | ||
|
||
export POSTGRES_HOST=localhost | ||
export POSTGRES_SSL=disable | ||
export POSTGRES_DB=postgres | ||
export POSTGRES_USER=postgres | ||
export YIPEE_TEAM_OWNER=$TOKEN_USER | ||
|
||
docker-compose -f PostgreSQL.yml up -d | ||
bash gobuild.sh | ||
result=$? | ||
docker-compose -f PostgreSQL.yml down | ||
docker volume rm auth_data >& /dev/null | ||
test $result -eq 0 || exit 1 | ||
IMAGE=auth | ||
docker build -t $REGISTRY/$IMAGE . | ||
docker tag $REGISTRY/$IMAGE yipee-tools-spoke-cos.ca.com:5000/$IMAGE:development | ||
|
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,84 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
type metadata struct { | ||
CreationTimestamp *string | ||
GenerateName string | ||
Labels *[]label | ||
Name string | ||
Namespace string | ||
OwnerReferences *[]resource | ||
ResourceVersion string | ||
SelfLink string | ||
Uid string | ||
} | ||
|
||
type metadataResolver struct { | ||
ctx context.Context | ||
m *metadata | ||
} | ||
|
||
func (r *metadataResolver) CreationTimestamp() *string { | ||
return r.m.CreationTimestamp | ||
} | ||
|
||
func (r *metadataResolver) GenerateName() string { | ||
return r.m.GenerateName | ||
} | ||
|
||
func (r *metadataResolver) Labels() []*labelResolver { | ||
var labelResolvers []*labelResolver | ||
labels := r.m.Labels | ||
if labels == nil { | ||
labels = getMetadataLabels(r.m) | ||
} | ||
for _, label := range *labels { | ||
lab := label | ||
labelResolvers = append(labelResolvers, &labelResolver{r.ctx, &lab}) | ||
} | ||
return labelResolvers | ||
} | ||
|
||
func (r *metadataResolver) Name() string { | ||
return r.m.Name | ||
} | ||
|
||
func (r *metadataResolver) Namespace() string { | ||
return r.m.Namespace | ||
} | ||
|
||
func (r *metadataResolver) OwnerReferences() []*resourceResolver { | ||
var ownerResolvers []*resourceResolver | ||
owners := r.m.OwnerReferences | ||
if owners == nil { | ||
owners = getMetadataOwnerReferences(r.m) | ||
} | ||
for _, owner := range *owners { | ||
own := owner | ||
ownerResolvers = append(ownerResolvers, &resourceResolver{r.ctx, &own}) | ||
} | ||
return ownerResolvers | ||
} | ||
|
||
func (r *metadataResolver) ResourceVersion() string { | ||
return r.m.ResourceVersion | ||
} | ||
|
||
func (r *metadataResolver) SelfLink() string { | ||
return r.m.SelfLink | ||
} | ||
|
||
func (r *metadataResolver) Uid() string { | ||
return r.m.Uid | ||
} | ||
|
||
func getMetadataLabels(m *metadata) *[]label { | ||
return nil | ||
} | ||
|
||
func getMetadataOwnerReferences(m *metadata) *[]resource { | ||
return nil | ||
} |
Oops, something went wrong.