Skip to content

Commit

Permalink
switch to koki/short/yaml; fix probe port
Browse files Browse the repository at this point in the history
  • Loading branch information
ublubu committed Dec 20, 2017
1 parent 72f9015 commit 39cda7c
Show file tree
Hide file tree
Showing 33 changed files with 63 additions and 102 deletions.
3 changes: 1 addition & 2 deletions client/client.go
Expand Up @@ -3,12 +3,11 @@ package client
import (
"io"

"github.com/ghodss/yaml"

"github.com/koki/json"
"github.com/koki/json/jsonutil"
"github.com/koki/short/converter"
"github.com/koki/short/parser"
"github.com/koki/short/yaml"
serrors "github.com/koki/structurederrors"
)

Expand Down
4 changes: 1 addition & 3 deletions cmd/short.go
@@ -1,15 +1,13 @@
package cmd

import (
"github.com/ghodss/yaml"
"github.com/golang/glog"

// Just make sure we also build the client package.
"github.com/koki/json/jsonutil"
_ "github.com/koki/short/client"
"github.com/koki/short/converter"
"github.com/koki/short/imports"
"github.com/koki/short/parser"
"github.com/koki/short/yaml"
serrors "github.com/koki/structurederrors"
)

Expand Down
3 changes: 1 addition & 2 deletions converter/converters/koki_controllerrevision_to_kube.go
Expand Up @@ -5,10 +5,9 @@ import (
appsv1beta1 "k8s.io/api/apps/v1beta1"
appsv1beta2 "k8s.io/api/apps/v1beta2"

"github.com/ghodss/yaml"

"github.com/koki/short/parser"
"github.com/koki/short/types"
"github.com/koki/short/yaml"
serrors "github.com/koki/structurederrors"
)

Expand Down
3 changes: 1 addition & 2 deletions converter/converters/koki_cronjob_to_kube_cronjob.go
Expand Up @@ -5,10 +5,9 @@ import (
batchv2alpha1 "k8s.io/api/batch/v2alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/ghodss/yaml"

"github.com/koki/short/parser"
"github.com/koki/short/types"
"github.com/koki/short/yaml"
serrors "github.com/koki/structurederrors"
)

Expand Down
3 changes: 1 addition & 2 deletions converter/converters/koki_daemonset_to_kube_daemonset.go
Expand Up @@ -4,10 +4,9 @@ import (
appsv1beta2 "k8s.io/api/apps/v1beta2"
exts "k8s.io/api/extensions/v1beta1"

"github.com/ghodss/yaml"

"github.com/koki/short/parser"
"github.com/koki/short/types"
"github.com/koki/short/yaml"
serrors "github.com/koki/structurederrors"
)

Expand Down
3 changes: 1 addition & 2 deletions converter/converters/koki_deployment_to_kube_deployment.go
Expand Up @@ -5,10 +5,9 @@ import (
appsv1beta2 "k8s.io/api/apps/v1beta2"
exts "k8s.io/api/extensions/v1beta1"

"github.com/ghodss/yaml"

"github.com/koki/short/parser"
"github.com/koki/short/types"
"github.com/koki/short/yaml"
serrors "github.com/koki/structurederrors"
)

Expand Down
41 changes: 12 additions & 29 deletions converter/converters/koki_pod_to_kube_v1_pod.go
Expand Up @@ -1603,36 +1603,21 @@ func revertProbe(probe *types.Probe) (*v1.Probe, error) {
if err != nil {
return nil, serrors.InvalidInstanceContextErrorf(err, probe, "parsing URL")
}
fields := strings.Split(urlStruct.Host, ":")
if len(fields) != 2 && len(fields) != 1 {
return nil, serrors.InvalidInstanceErrorf(urlStruct, "unrecognized Probe Host")
}
host := fields[0]
port := intstr.FromString("80")
if len(fields) == 2 {
port = intstr.Parse(fields[1])
}
if strings.ToUpper(urlStruct.Scheme) == "TCP" {
hostPort := urlStruct.Host
fields := strings.Split(hostPort, ":")
if len(fields) != 2 && len(fields) != 1 {
return nil, serrors.InvalidInstanceErrorf(urlStruct, "unrecognized Probe Host")
}
host := fields[0]
port := "80"
if len(fields) == 2 {
port = fields[1]
}
kubeProbe.TCPSocket = &v1.TCPSocketAction{
Host: host,
Port: intstr.IntOrString{
StrVal: port,
},
Port: port,
}
} else if strings.ToUpper(urlStruct.Scheme) == "HTTP" || strings.ToUpper(urlStruct.Scheme) == "HTTPS" {

hostPort := urlStruct.Host
fields := strings.Split(hostPort, ":")
if len(fields) != 2 && len(fields) != 1 {
return nil, serrors.InvalidInstanceErrorf(urlStruct, "unrecognized Probe Host")
}
host := fields[0]
port := "80"
if len(fields) == 2 {
port = fields[1]
}

var scheme v1.URIScheme

if strings.ToLower(urlStruct.Scheme) == "http" {
Expand All @@ -1646,10 +1631,8 @@ func revertProbe(probe *types.Probe) (*v1.Probe, error) {
kubeProbe.HTTPGet = &v1.HTTPGetAction{
Scheme: scheme,
Path: urlStruct.Path,
Port: intstr.IntOrString{
StrVal: port,
},
Host: host,
Host: host,
Port: port,
}

var headers []v1.HTTPHeader
Expand Down
3 changes: 1 addition & 2 deletions converter/converters/koki_replicaset_to_kube_replicaset.go
Expand Up @@ -7,11 +7,10 @@ import (
exts "k8s.io/api/extensions/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/ghodss/yaml"

"github.com/koki/short/parser"
"github.com/koki/short/parser/expressions"
"github.com/koki/short/types"
"github.com/koki/short/yaml"
serrors "github.com/koki/structurederrors"
)

Expand Down
3 changes: 1 addition & 2 deletions converter/converters/koki_statefulset_to_kube_statefulset.go
Expand Up @@ -5,10 +5,9 @@ import (
appsv1beta2 "k8s.io/api/apps/v1beta2"
"k8s.io/api/core/v1"

"github.com/ghodss/yaml"

"github.com/koki/short/parser"
"github.com/koki/short/types"
"github.com/koki/short/yaml"
serrors "github.com/koki/structurederrors"
)

Expand Down
Expand Up @@ -4,10 +4,9 @@ import (
storagev1 "k8s.io/api/storage/v1"
storagev1beta1 "k8s.io/api/storage/v1beta1"

"github.com/ghodss/yaml"

"github.com/koki/short/parser"
"github.com/koki/short/types"
"github.com/koki/short/yaml"
serrors "github.com/koki/structurederrors"
)

Expand Down
3 changes: 1 addition & 2 deletions converter/converters/kube_controllerrevision_to_koki.go
Expand Up @@ -4,10 +4,9 @@ import (
apps "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/runtime"

"github.com/ghodss/yaml"

"github.com/koki/short/parser"
"github.com/koki/short/types"
"github.com/koki/short/yaml"
serrors "github.com/koki/structurederrors"
)

Expand Down
2 changes: 1 addition & 1 deletion converter/converters/kube_cronjob_to_koki_cronjob.go
@@ -1,12 +1,12 @@
package converters

import (
"github.com/ghodss/yaml"
batchv1beta1 "k8s.io/api/batch/v1beta1"
"k8s.io/apimachinery/pkg/runtime"

"github.com/koki/short/parser"
"github.com/koki/short/types"
"github.com/koki/short/yaml"
serrors "github.com/koki/structurederrors"
)

Expand Down
3 changes: 1 addition & 2 deletions converter/converters/kube_daemonset_to_koki_daemonset.go
Expand Up @@ -5,10 +5,9 @@ import (
"k8s.io/apimachinery/pkg/runtime"
intstr "k8s.io/apimachinery/pkg/util/intstr"

"github.com/ghodss/yaml"

"github.com/koki/short/parser"
"github.com/koki/short/types"
"github.com/koki/short/yaml"
serrors "github.com/koki/structurederrors"
)

Expand Down
3 changes: 1 addition & 2 deletions converter/converters/kube_deployment_to_koki_deployment.go
Expand Up @@ -5,10 +5,9 @@ import (
"k8s.io/apimachinery/pkg/runtime"
intstr "k8s.io/apimachinery/pkg/util/intstr"

"github.com/ghodss/yaml"

"github.com/koki/short/parser"
"github.com/koki/short/types"
"github.com/koki/short/yaml"
serrors "github.com/koki/structurederrors"
)

Expand Down
3 changes: 1 addition & 2 deletions converter/converters/kube_replicaset_to_koki_replicaset.go
Expand Up @@ -7,11 +7,10 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"

"github.com/ghodss/yaml"

"github.com/koki/short/parser"
"github.com/koki/short/parser/expressions"
"github.com/koki/short/types"
"github.com/koki/short/yaml"
serrors "github.com/koki/structurederrors"
)

Expand Down
3 changes: 1 addition & 2 deletions converter/converters/kube_statefulset_to_koki_statefulset.go
Expand Up @@ -5,10 +5,9 @@ import (
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"

"github.com/ghodss/yaml"

"github.com/koki/short/parser"
"github.com/koki/short/types"
"github.com/koki/short/yaml"
serrors "github.com/koki/structurederrors"
)

Expand Down
3 changes: 1 addition & 2 deletions converter/converters/kube_storageclass_to_koki.go
Expand Up @@ -4,10 +4,9 @@ import (
storagev1 "k8s.io/api/storage/v1"
"k8s.io/apimachinery/pkg/runtime"

"github.com/ghodss/yaml"

"github.com/koki/short/parser"
"github.com/koki/short/types"
"github.com/koki/short/yaml"
serrors "github.com/koki/structurederrors"
)

Expand Down
3 changes: 2 additions & 1 deletion imports/eval_test.go
Expand Up @@ -5,8 +5,9 @@ import (
"reflect"
"testing"

"github.com/ghodss/yaml"
"github.com/kr/pretty"

"github.com/koki/short/yaml"
)

var evalModules = map[string]string{
Expand Down
3 changes: 2 additions & 1 deletion imports/imports_test.go
Expand Up @@ -4,8 +4,9 @@ import (
"fmt"
"testing"

"github.com/ghodss/yaml"
"github.com/kr/pretty"

"github.com/koki/short/yaml"
)

var modules = map[string]string{
Expand Down
3 changes: 1 addition & 2 deletions parser/kube.go
Expand Up @@ -4,8 +4,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"

"github.com/ghodss/yaml"

"github.com/koki/short/yaml"
serrors "github.com/koki/structurederrors"
)

Expand Down
2 changes: 1 addition & 1 deletion template/template_test.go
Expand Up @@ -4,7 +4,7 @@ import (
"strings"
"testing"

"github.com/ghodss/yaml"
"github.com/koki/short/yaml"
)

var template0 = `
Expand Down
1 change: 0 additions & 1 deletion testdata/crds/crd.short.yaml
@@ -1,5 +1,4 @@
crd:
accepted: {}
meta:
group: stable.example.com
kind: CronTab
Expand Down
7 changes: 2 additions & 5 deletions testdata/pods/pod_spec_with_containers.rekube.yaml
Expand Up @@ -4,7 +4,6 @@ metadata:
annotations:
meta: _test
clusterName: test_cluster
creationTimestamp: null
labels:
app: meta_test
name: meta_test
Expand All @@ -29,7 +28,6 @@ spec:
- name: key
valueFrom:
resourceFieldRef:
divisor: "0"
resource: requests.cpu
- name: key
valueFrom:
Expand Down Expand Up @@ -75,7 +73,7 @@ spec:
- name: X-Custom-Header
value: Awesome
path: /healthz
port: 0
port: 8080
scheme: HTTP
initialDelaySeconds: 3
periodSeconds: 3
Expand All @@ -89,7 +87,7 @@ spec:
initialDelaySeconds: 5
periodSeconds: 10
tcpSocket:
port: 0
port: 8080
resources:
limits:
cpu: "1"
Expand Down Expand Up @@ -150,5 +148,4 @@ spec:
path: /path/to/host/vol
type: Directory
name: host_path_test_volume
status: {}

8 changes: 2 additions & 6 deletions testdata/pods/pod_spec_with_init_containers.rekube.yaml
Expand Up @@ -4,7 +4,6 @@ metadata:
annotations:
meta: _test
clusterName: test_cluster
creationTimestamp: null
labels:
app: meta_test
name: meta_test
Expand All @@ -30,7 +29,6 @@ spec:
- name: key
valueFrom:
resourceFieldRef:
divisor: "0"
resource: requests.cpu
- name: key
valueFrom:
Expand Down Expand Up @@ -76,7 +74,7 @@ spec:
- name: X-Custom-Header
value: Awesome
path: /healthz
port: 0
port: 8080
scheme: HTTP
initialDelaySeconds: 3
periodSeconds: 3
Expand All @@ -90,7 +88,7 @@ spec:
initialDelaySeconds: 5
periodSeconds: 10
tcpSocket:
port: 0
port: 8080
resources:
limits:
cpu: "1"
Expand Down Expand Up @@ -161,9 +159,7 @@ status:
initContainerStatuses:
- image: ""
imageID: ""
lastState: {}
name: ""
ready: false
restartCount: 0
state: {}

0 comments on commit 39cda7c

Please sign in to comment.