Merge pull request #103 from monopole/addTravis

Add travis CICD coverage.
This commit is contained in:
Jeff Regan 2017-10-24 21:37:36 -07:00 committed by GitHub
commit d249dff292
7 changed files with 100 additions and 8 deletions

17
.travis.yml Normal file
View File

@ -0,0 +1,17 @@
language: go
go:
- 1.9.x
go_import_path: k8s.io/kubectl
before_install:
- go get -u github.com/golang/lint/golint
- go get -u golang.org/x/tools/cmd/goimports
script:
- ./bin/pre-commit.sh
# TBD, suppressing for now.
notifications:
email: false

37
bin/pre-commit.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
if [ -n "$failIt" ]; then
echo "Expecting failIt to be empty."
exit 1
fi
tmp=$(gofmt -s -d -l . 2>&1 )
if [ -n "$tmp" ]; then
printf >&2 'gofmt failed for:\n%s\n' "$tmp"
failIt=1
fi
tmp=$(goimports -l .)
if [ -n "$tmp" ]; then
printf >&2 'goimports failed for:\n%s\n' "$tmp"
failIt=1
fi
tmp=$(go vet -all ./... 2>&1)
if [ -n "$tmp" ]; then
printf >&2 'govet failed for:\n%s\n' "$tmp"
failIt=1
fi
tmp=$(golint ./...)
if [ -n "$tmp" ]; then
printf >&2 'golint failed for:\n%s\n' "$tmp"
failIt=1
fi
if [ -n "$failIt" ]; then
unset failIt
exit 1
fi
go test -v ./...

View File

@ -1,8 +1,8 @@
# kexpand
# kinflate
_TODO: flesh out this placeholder documentation_
`kexpand` is a kubernetes cluster configuration utility,
`kinflate` is a kubernetes cluster configuration utility,
a prototype of ideas discussed in [this doc][DAM].
It accepts one or more file system path arguments,
@ -29,7 +29,7 @@ For example, if your current working directory contained
then the command
```
kexpand ./mycluster/instances | kubectl apply -f -
kinflate ./mycluster/instances | kubectl apply -f -
```
would modify your cluster per the resources
generated from the manifests and associated

View File

@ -20,6 +20,12 @@ import (
"fmt"
)
func main() {
// TestableMain allows test coverage for main.
func TestableMain() error {
fmt.Println("Hello world.")
return nil
}
func main() {
TestableMain()
}

32
cmd/kinflate/main_test.go Normal file
View File

@ -0,0 +1,32 @@
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"testing"
)
// TODO: real tests
// e.g. make an inmemory file system, put yaml in there, inflate it
// to a buffer, compare to expected results, etc.
// a script in there, have script write file
func TestTrueMain(t *testing.T) {
err := TestableMain()
if err != nil {
t.Errorf("Unexpected error: %v", err)
}
}

View File

@ -98,14 +98,14 @@ type Manifest struct {
// If a secret want to have a base and an overlay, it should go to Bases and Overlays fields.
Secrets []Secret `json:"secrets,omitempty" yaml:"secrets,omitempty"`
// Whether prune resources not defined in Kube-manifest.yaml, similar to `kubectl apply --prune` behavior.
// Whether prune resources not defined in Kube-manifest.yaml, similar to `kubectl apply --prune` behavior.
Prune bool `json:"prune,omitempty" yaml:"prune,omitempty"`
// TODO: figure out what the behavior details should be.
// TODO: figure out what the behavior details should be.
// Whether PersistentVolumeClaims should be deleted with the other resources.
// OwnPersistentVolumeClaims bool `json:"ownPersistentVolumeClaims,omitempty" yaml:"ownPersistentVolumeClaims,omitempty"`
// TODO: figure out what the behavior details should be.
// TODO: figure out what the behavior details should be.
// Whether recursive look for Kube-manifest.yaml, similar to `kubectl --recursive` behavior.
// Recursive bool `json:"recursive,omitempty" yaml:"recursive,omitempty"`
}
@ -139,7 +139,7 @@ type Secret struct {
// TLS secret.
TLS TLS `json:"tls,omitempty" yaml:"tls,omitempty"`
// TODO: support more secret types, e.g. DockerRegistry
// TODO: support more secret types, e.g. DockerRegistry
}
// Generic contains some generic sources for configmap or secret.