Skip to content
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #10 from aledbf/badges
Browse files Browse the repository at this point in the history
Add badges
  • Loading branch information
aledbf authored Sep 9, 2017
2 parents 8e37b44 + c4c396f commit d00daed
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 154 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ notifications:
go:
- 1.9

go_import_path: github.com/aledbf/kube-keepalived
go_import_path: github.com/aledbf/kube-keepalived-vip

env:
global:
# to add additional secure variables:
# docker run --rm caktux/travis-cli encrypt key=value -r kubernetes/ingress
# docker run --rm caktux/travis-cli encrypt key=value -r kube-keepalived-vip
- RELEASE="ci-${TRAVIS_BUILD_ID}"

jobs:
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Kubernetes Virtual IP address/es using [keepalived](http://www.keepalived.org)

AKA "how to set up virtual IP addresses in kubernetes using [IPVS - The Linux Virtual Server Project](http://www.linuxvirtualserver.org/software/ipvs.html)".

[![Build Status](https://travis-ci.org/aledbf/kube-keepalived.svg?branch=master)](https://travis-ci.org/aledbf/kube-keepalived)
[![Coverage Status](https://coveralls.io/repos/github/aledbf/kube-keepalived/badge.svg?branch=master)](https://coveralls.io/github/aledbf/kube-keepalived)
[![Go Report Card](https://goreportcard.com/badge/github.com/aledbf/kube-keepalived)](https://goreportcard.com/report/github.com/aledbf/kube-keepalived)


## Overview

Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ func TestParseNsSvcLVS(t *testing.T) {
Namespace string
Service string
ForwardMethod string
ExpectedOk bool
ErrorExpected bool
}{
"just service name": {"echoheaders", "", "", "", true},
"missing namespace": {"echoheaders:NAT", "", "", "", true},
"default forward method": {"default/echoheaders", "default", "echoheaders", "NAT", false},
"with forward method": {"default/echoheaders:NAT", "default", "echoheaders", "NAT", false},
"DR as forward method": {"default/echoheaders:DR", "", "", "", true},
"DR as forward method": {"default/echoheaders:DR", "default", "echoheaders", "DR", false},
"invalid forward method": {"default/echoheaders:AJAX", "", "", "", true},
}

for k, tc := range testcases {
ns, svc, lvs, err := parseNsSvcLVS(tc.Input)

if tc.ExpectedOk && err == nil {
if tc.ErrorExpected && err == nil {
t.Errorf("%s: expected an error but valid information returned: %v ", k, tc.Input)
}

Expand Down
149 changes: 0 additions & 149 deletions pkg/k8s/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,155 +25,6 @@ import (
testclient "k8s.io/client-go/kubernetes/fake"
)

func TestParseNameNS(t *testing.T) {
tests := []struct {
title string
input string
ns string
name string
expErr bool
}{
{"empty string", "", "", "", true},
{"demo", "demo", "", "", true},
{"kube-system", "kube-system", "", "", true},
{"default/kube-system", "default/kube-system", "default", "kube-system", false},
}

for _, test := range tests {
ns, name, err := ParseNameNS(test.input)
if test.expErr {
if err == nil {
t.Errorf("%v: expected error but returned nil", test.title)
}
continue
}
if test.ns != ns {
t.Errorf("%v: expected %v but returned %v", test.title, test.ns, ns)
}
if test.name != name {
t.Errorf("%v: expected %v but returned %v", test.title, test.name, name)
}
}
}

func TestIsValidService(t *testing.T) {
fk := testclient.NewSimpleClientset(&api.Service{
ObjectMeta: meta_v1.ObjectMeta{
Namespace: api.NamespaceDefault,
Name: "demo",
},
})

_, err := IsValidService(fk, "")
if err == nil {
t.Errorf("expected error but returned nil")
}
s, err := IsValidService(fk, "default/demo")
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if s == nil {
t.Errorf("expected a Service but returned nil")
}

fk = testclient.NewSimpleClientset()
s, err = IsValidService(fk, "default/demo")
if err == nil {
t.Errorf("expected an error but returned nil")
}
if s != nil {
t.Errorf("unexpected Service returned: %v", s)
}
}

func TestIsValidNamespace(t *testing.T) {

fk := testclient.NewSimpleClientset(&api.Namespace{
ObjectMeta: meta_v1.ObjectMeta{
Name: "default",
},
})

_, err := IsValidNamespace(fk, "empty")
if err == nil {
t.Errorf("expected error but return nill")
}

ns, err := IsValidNamespace(fk, "default")
if err != nil {
t.Errorf("unexpected error: %v", err)
}

if ns == nil {
t.Errorf("expected a configmap but returned nil")
}

}

func TestIsValidConfigMap(t *testing.T) {

fk := testclient.NewSimpleClientset(&api.ConfigMap{
ObjectMeta: meta_v1.ObjectMeta{
Namespace: api.NamespaceDefault,
Name: "demo",
},
})

_, err := IsValidConfigMap(fk, "")
if err == nil {
t.Errorf("expected error but return nill")
}

s, err := IsValidConfigMap(fk, "default/demo")
if err != nil {
t.Errorf("unexpected error: %v", err)
}

if s == nil {
t.Errorf("expected a configmap but returned nil")
}

fk = testclient.NewSimpleClientset()
s, err = IsValidConfigMap(fk, "default/demo")
if err == nil {
t.Errorf("expected an error but returned nil")
}
if s != nil {
t.Errorf("unexpected Configmap returned: %v", s)
}

}

func TestIsValidSecret(t *testing.T) {
fk := testclient.NewSimpleClientset(&api.Secret{
ObjectMeta: meta_v1.ObjectMeta{
Namespace: api.NamespaceDefault,
Name: "demo",
},
})

_, err := IsValidSecret(fk, "")
if err == nil {
t.Errorf("expected error but returned nil")
}
s, err := IsValidSecret(fk, "default/demo")
if err != nil {
t.Errorf("unexpected error: %v", err)
}
if s == nil {
t.Errorf("expected a Secret but returned nil")
}

fk = testclient.NewSimpleClientset()
s, err = IsValidSecret(fk, "default/demo")
if err == nil {
t.Errorf("expected an error but returned nil")
}
if s != nil {
t.Errorf("unexpected Secret returned: %v", s)
}
}

func TestGetNodeIP(t *testing.T) {
fKNodes := []struct {
cs *testclient.Clientset
Expand Down

0 comments on commit d00daed

Please sign in to comment.