Merge pull request #483 from procrypt/empty_vols

delete objects based on label
This commit is contained in:
Tomas Kral 2017-03-24 12:11:29 +01:00 committed by GitHub
commit 3c3ae9807a
111 changed files with 3131 additions and 4010 deletions

33
glide.lock generated
View File

@ -1,5 +1,5 @@
hash: a1dbf2b8c2789bec3a0e75cb5a24273d1b8ec9b38a1ef1b351eda824cdd56ae7 hash: a1dbf2b8c2789bec3a0e75cb5a24273d1b8ec9b38a1ef1b351eda824cdd56ae7
updated: 2017-03-15T13:16:48.661724768+05:30 updated: 2017-03-17T01:50:53.646322363+05:30
imports: imports:
- name: cloud.google.com/go - name: cloud.google.com/go
version: 3b1ae45394a234c385be014e9a488f2bb6eef821 version: 3b1ae45394a234c385be014e9a488f2bb6eef821
@ -210,11 +210,11 @@ imports:
- name: github.com/evanphx/json-patch - name: github.com/evanphx/json-patch
version: 465937c80b3c07a7c7ad20cc934898646a91c1de version: 465937c80b3c07a7c7ad20cc934898646a91c1de
- name: github.com/fatih/structs - name: github.com/fatih/structs
version: be738c8546f55b34e60125afa50ed73a9a9c460e version: dc3312cb1a4513a366c4c9e622ad55c32df12ed3
- name: github.com/flynn/go-shlex - name: github.com/flynn/go-shlex
version: 3f9db97f856818214da2e1057f8ad84803971cff version: 3f9db97f856818214da2e1057f8ad84803971cff
- name: github.com/fsnotify/fsnotify - name: github.com/fsnotify/fsnotify
version: 7d7316ed6e1ed2de075aab8dfc76de5d158d66e1 version: 629574ca2a5df945712d3079857300b5e4da0236
- name: github.com/fsouza/go-dockerclient - name: github.com/fsouza/go-dockerclient
version: bf97c77db7c945cbcdbf09d56c6f87a66f54537b version: bf97c77db7c945cbcdbf09d56c6f87a66f54537b
subpackages: subpackages:
@ -332,7 +332,7 @@ imports:
- runtime/internal - runtime/internal
- utilities - utilities
- name: github.com/hashicorp/hcl - name: github.com/hashicorp/hcl
version: 630949a3c5fa3c613328e1b8256052cbc2327c9b version: 7cb7455c285ca3bf3362aa4ba6a06a6d6f5c3ba0
subpackages: subpackages:
- hcl/ast - hcl/ast
- hcl/parser - hcl/parser
@ -351,13 +351,13 @@ imports:
- name: github.com/juju/ratelimit - name: github.com/juju/ratelimit
version: 77ed1c8a01217656d2080ad51981f6e99adaa177 version: 77ed1c8a01217656d2080ad51981f6e99adaa177
- name: github.com/magiconair/properties - name: github.com/magiconair/properties
version: b3b15ef068fd0b17ddf408a23669f20811d194d2 version: c265cfa48dda6474e208715ca93e987829f572f8
- name: github.com/matttproud/golang_protobuf_extensions - name: github.com/matttproud/golang_protobuf_extensions
version: fc2b8d3a73c4867e51861bbdd5ae3c1f0869dd6a version: fc2b8d3a73c4867e51861bbdd5ae3c1f0869dd6a
subpackages: subpackages:
- pbutil - pbutil
- name: github.com/mitchellh/mapstructure - name: github.com/mitchellh/mapstructure
version: 53818660ed4955e899c0bcafa97299a388bd7c8e version: f3009df150dadf309fdee4a54ed65c124afad715
- name: github.com/openshift/origin - name: github.com/openshift/origin
version: b4e0954faa4a0d11d9c1a536b76ad4a8c0206b7c version: b4e0954faa4a0d11d9c1a536b76ad4a8c0206b7c
subpackages: subpackages:
@ -403,11 +403,11 @@ imports:
- name: github.com/pborman/uuid - name: github.com/pborman/uuid
version: ca53cad383cad2479bbba7f7a1a05797ec1386e4 version: ca53cad383cad2479bbba7f7a1a05797ec1386e4
- name: github.com/pelletier/go-buffruneio - name: github.com/pelletier/go-buffruneio
version: c37440a7cf42ac63b919c752ca73a85067e05992 version: df1e16fde7fc330a0ca68167c23bf7ed6ac31d6d
- name: github.com/pelletier/go-toml - name: github.com/pelletier/go-toml
version: fee7787d3f811af92276f5ff10107092e95b7a1d version: 64ff1ea4d585bc1fca65e6331eb8239f2ff31845
- name: github.com/pkg/errors - name: github.com/pkg/errors
version: bfd5150e4e41705ded2129ec33379de1cb90b513 version: 248dadf4e9068a0b3e79f02ed0a610d935de5302
- name: github.com/prometheus/client_golang - name: github.com/prometheus/client_golang
version: e51041b3fa41cece0dca035740ba6411905be473 version: e51041b3fa41cece0dca035740ba6411905be473
subpackages: subpackages:
@ -425,31 +425,31 @@ imports:
- name: github.com/prometheus/procfs - name: github.com/prometheus/procfs
version: 454a56f35412459b5e684fd5ec0f9211b94f002a version: 454a56f35412459b5e684fd5ec0f9211b94f002a
- name: github.com/Sirupsen/logrus - name: github.com/Sirupsen/logrus
version: 4b6ea7319e214d98c938f12692336f7ca9348d6b version: aaf92c95712104318fc35409745f1533aa5ff327
- name: github.com/spf13/afero - name: github.com/spf13/afero
version: 9be650865eab0c12963d8753212f4f9c66cdcf12 version: 06b7e5f50606ecd49148a01a6008942d9b669217
subpackages: subpackages:
- mem - mem
- name: github.com/spf13/cast - name: github.com/spf13/cast
version: ce135a4ebeee6cfe9a26c93ee0d37825f26113c7 version: 24b6558033ffe202bf42f0f3b870dcc798dd2ba8
- name: github.com/spf13/cobra - name: github.com/spf13/cobra
version: 7c674d9e72017ed25f6d2b5e497a1368086b6a6f version: 7c674d9e72017ed25f6d2b5e497a1368086b6a6f
- name: github.com/spf13/jwalterweatherman - name: github.com/spf13/jwalterweatherman
version: fa7ca7e836cf3a8bb4ebf799f472c12d7e903d66 version: 33c24e77fb80341fe7130ee7c594256ff08ccc46
- name: github.com/spf13/pflag - name: github.com/spf13/pflag
version: 5ccb023bc27df288a957c5e994cd44fd19619465 version: 5ccb023bc27df288a957c5e994cd44fd19619465
- name: github.com/spf13/viper - name: github.com/spf13/viper
version: 0b5690fd875739811249ca79d24afd8f89f188c6 version: 651d9d916abc3c3d6a91a12549495caba5edffd2
- name: github.com/ugorji/go - name: github.com/ugorji/go
version: f4485b318aadd133842532f841dc205a8e339d74 version: f4485b318aadd133842532f841dc205a8e339d74
subpackages: subpackages:
- codec - codec
- name: github.com/xeipuuv/gojsonpointer - name: github.com/xeipuuv/gojsonpointer
version: e0fe6f68307607d540ed8eac07a342c33fa1b54a version: 6fe8760cad3569743d51ddbb243b26f8456742dc
- name: github.com/xeipuuv/gojsonreference - name: github.com/xeipuuv/gojsonreference
version: e02fc20de94c78484cd5ffb007f8af96be030a45 version: e02fc20de94c78484cd5ffb007f8af96be030a45
- name: github.com/xeipuuv/gojsonschema - name: github.com/xeipuuv/gojsonschema
version: ac452913faa25c08bb78810d3e6f88b8a39f8f25 version: ff0417f4272e480246b4507459b3f6ae721a87ac
- name: golang.org/x/net - name: golang.org/x/net
version: e90d6d0afc4c315a0d87a568ae68577cc15149a0 version: e90d6d0afc4c315a0d87a568ae68577cc15149a0
subpackages: subpackages:
@ -476,6 +476,7 @@ imports:
version: 833a04a10549a95dc34458c195cbad61bbb6cb4d version: 833a04a10549a95dc34458c195cbad61bbb6cb4d
subpackages: subpackages:
- unix - unix
- windows
- name: golang.org/x/text - name: golang.org/x/text
version: ceefd2213ed29504fff30155163c8f59827734f3 version: ceefd2213ed29504fff30155163c8f59827734f3
subpackages: subpackages:

View File

@ -47,6 +47,8 @@ import (
"k8s.io/kubernetes/pkg/util/intstr" "k8s.io/kubernetes/pkg/util/intstr"
//"k8s.io/kubernetes/pkg/controller/daemon" //"k8s.io/kubernetes/pkg/controller/daemon"
"github.com/pkg/errors" "github.com/pkg/errors"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/labels"
) )
// Kubernetes implements Transformer interface and represents Kubernetes transformer // Kubernetes implements Transformer interface and represents Kubernetes transformer
@ -250,7 +252,8 @@ func (k *Kubernetes) CreatePVC(name string, mode string) (*api.PersistentVolumeC
APIVersion: "v1", APIVersion: "v1",
}, },
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Name: name, Name: name,
Labels: transformer.ConfigLabels(name),
}, },
Spec: api.PersistentVolumeClaimSpec{ Spec: api.PersistentVolumeClaimSpec{
Resources: api.ResourceRequirements{ Resources: api.ResourceRequirements{
@ -702,40 +705,67 @@ func (k *Kubernetes) Undeploy(komposeObject kobject.KomposeObject, opt kobject.C
} }
for _, v := range objects { for _, v := range objects {
label := labels.SelectorFromSet(labels.Set(map[string]string{transformer.Selector: v.(meta.Object).GetName()}))
options := api.ListOptions{LabelSelector: label}
komposeLabel := map[string]string{transformer.Selector: v.(meta.Object).GetName()}
switch t := v.(type) { switch t := v.(type) {
case *extensions.Deployment: case *extensions.Deployment:
//delete deployment //delete deployment
rpDeployment, err := kubectl.ReaperFor(extensions.Kind("Deployment"), client) deployment, err := client.Deployments(namespace).List(options)
if err != nil { if err != nil {
return err return err
} }
//FIXME: gracePeriod is nil for _, l := range deployment.Items {
err = rpDeployment.Stop(namespace, t.Name, TIMEOUT*time.Second, nil) if reflect.DeepEqual(l.Labels, komposeLabel) {
if err != nil { rpDeployment, err := kubectl.ReaperFor(extensions.Kind("Deployment"), client)
return err if err != nil {
return err
}
//FIXME: gracePeriod is nil
err = rpDeployment.Stop(namespace, t.Name, TIMEOUT*time.Second, nil)
if err != nil {
return err
}
log.Infof("Successfully deleted Deployment: %s", t.Name)
}
} }
log.Infof("Successfully deleted Deployment: %s", t.Name)
case *api.Service: case *api.Service:
//delete svc //delete svc
rpService, err := kubectl.ReaperFor(api.Kind("Service"), client) svc, err := client.Services(namespace).List(options)
if err != nil { if err != nil {
return err return err
} }
//FIXME: gracePeriod is nil for _, l := range svc.Items {
err = rpService.Stop(namespace, t.Name, TIMEOUT*time.Second, nil) if reflect.DeepEqual(l.Labels, komposeLabel) {
if err != nil { rpService, err := kubectl.ReaperFor(api.Kind("Service"), client)
return err if err != nil {
return err
}
//FIXME: gracePeriod is nil
err = rpService.Stop(namespace, t.Name, TIMEOUT*time.Second, nil)
if err != nil {
return err
}
log.Infof("Successfully deleted Service: %s", t.Name)
}
} }
log.Infof("Successfully deleted Service: %s", t.Name)
case *api.PersistentVolumeClaim: case *api.PersistentVolumeClaim:
// delete pvc // delete pvc
err = client.PersistentVolumeClaims(namespace).Delete(t.Name) pvc, err := client.PersistentVolumeClaims(namespace).List(options)
if err != nil { if err != nil {
return err return err
} }
log.Infof("Successfully deleted PersistentVolumeClaim: %s", t.Name) for _, l := range pvc.Items {
if reflect.DeepEqual(l.Labels, komposeLabel) {
err = client.PersistentVolumeClaims(namespace).Delete(t.Name)
if err != nil {
return err
}
log.Infof("Successfully deleted PersistentVolumeClaim: %s", t.Name)
}
}
case *extensions.Ingress: case *extensions.Ingress:
// delete ingress // delete ingress
@ -745,23 +775,41 @@ func (k *Kubernetes) Undeploy(komposeObject kobject.KomposeObject, opt kobject.C
APIVersion: "extensions/v1beta1", APIVersion: "extensions/v1beta1",
}, },
} }
err = client.Ingress(namespace).Delete(t.Name, ingDeleteOptions) ingress, err := client.Ingress(namespace).List(options)
if err != nil { if err != nil {
return err return err
} }
log.Infof("Successfully deleted Ingress: %s", t.Name) for _, l := range ingress.Items {
if reflect.DeepEqual(l.Labels, komposeLabel) {
err = client.Ingress(namespace).Delete(t.Name, ingDeleteOptions)
if err != nil {
return err
}
log.Infof("Successfully deleted Ingress: %s", t.Name)
}
}
case *api.Pod: case *api.Pod:
rpPod, err := kubectl.ReaperFor(api.Kind("Pod"), client) //delete pod
pod, err := client.Pods(namespace).List(options)
if err != nil { if err != nil {
return err return err
} }
//FIXME: gracePeriod is nil for _, l := range pod.Items {
err = rpPod.Stop(namespace, t.Name, TIMEOUT*time.Second, nil) if reflect.DeepEqual(l.Labels, komposeLabel) {
if err != nil { rpPod, err := kubectl.ReaperFor(api.Kind("Pod"), client)
return err if err != nil {
return err
}
//FIXME: gracePeriod is nil
err = rpPod.Stop(namespace, t.Name, TIMEOUT*time.Second, nil)
if err != nil {
return err
}
log.Infof("Successfully deleted Pod: %s", t.Name)
}
} }
log.Infof("Successfully deleted Pod: %s", t.Name)
} }
} }
return nil return nil

View File

@ -39,14 +39,18 @@ import (
"time" "time"
"github.com/kubernetes-incubator/kompose/pkg/transformer"
buildapi "github.com/openshift/origin/pkg/build/api" buildapi "github.com/openshift/origin/pkg/build/api"
deployapi "github.com/openshift/origin/pkg/deploy/api" deployapi "github.com/openshift/origin/pkg/deploy/api"
deploymentconfigreaper "github.com/openshift/origin/pkg/deploy/cmd" deploymentconfigreaper "github.com/openshift/origin/pkg/deploy/cmd"
imageapi "github.com/openshift/origin/pkg/image/api" imageapi "github.com/openshift/origin/pkg/image/api"
routeapi "github.com/openshift/origin/pkg/route/api" routeapi "github.com/openshift/origin/pkg/route/api"
"github.com/pkg/errors" "github.com/pkg/errors"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/kubectl" "k8s.io/kubernetes/pkg/kubectl"
"k8s.io/kubernetes/pkg/labels"
"k8s.io/kubernetes/pkg/util/intstr" "k8s.io/kubernetes/pkg/util/intstr"
"reflect"
) )
// OpenShift implements Transformer interface and represents OpenShift transformer // OpenShift implements Transformer interface and represents OpenShift transformer
@ -161,7 +165,8 @@ func (o *OpenShift) initImageStream(name string, service kobject.ServiceConfig)
APIVersion: "v1", APIVersion: "v1",
}, },
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Name: name, Name: name,
Labels: transformer.ConfigLabels(name),
}, },
Spec: imageapi.ImageStreamSpec{ Spec: imageapi.ImageStreamSpec{
Tags: tags, Tags: tags,
@ -233,15 +238,15 @@ func (o *OpenShift) initDeploymentConfig(name string, service kobject.ServiceCon
}, },
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Name: name, Name: name,
Labels: map[string]string{"service": name}, Labels: transformer.ConfigLabels(name),
}, },
Spec: deployapi.DeploymentConfigSpec{ Spec: deployapi.DeploymentConfigSpec{
Replicas: int32(replicas), Replicas: int32(replicas),
Selector: map[string]string{"service": name}, Selector: transformer.ConfigLabels(name),
//UniqueLabelKey: p.Name, //UniqueLabelKey: p.Name,
Template: &api.PodTemplateSpec{ Template: &api.PodTemplateSpec{
ObjectMeta: api.ObjectMeta{ ObjectMeta: api.ObjectMeta{
Labels: map[string]string{"service": name}, Labels: transformer.ConfigLabels(name),
}, },
Spec: o.InitPodSpec(name, " "), Spec: o.InitPodSpec(name, " "),
}, },
@ -497,7 +502,6 @@ func (o *OpenShift) Undeploy(komposeObject kobject.KomposeObject, opt kobject.Co
if err != nil { if err != nil {
return errors.Wrap(err, "o.Transform failed") return errors.Wrap(err, "o.Transform failed")
} }
oclient, err := o.getOpenShiftClient() oclient, err := o.getOpenShiftClient()
if err != nil { if err != nil {
return err return err
@ -508,71 +512,132 @@ func (o *OpenShift) Undeploy(komposeObject kobject.KomposeObject, opt kobject.Co
} }
for _, v := range objects { for _, v := range objects {
label := labels.SelectorFromSet(labels.Set(map[string]string{transformer.Selector: v.(meta.Object).GetName()}))
options := api.ListOptions{LabelSelector: label}
komposeLabel := map[string]string{transformer.Selector: v.(meta.Object).GetName()}
switch t := v.(type) { switch t := v.(type) {
case *imageapi.ImageStream: case *imageapi.ImageStream:
//delete imageStream //delete imageStream
err = oclient.ImageStreams(namespace).Delete(t.Name) imageStream, err := oclient.ImageStreams(namespace).List(options)
if err != nil { if err != nil {
return err return err
} }
log.Infof("Successfully deleted ImageStream: %s", t.Name) for _, l := range imageStream.Items {
if reflect.DeepEqual(l.Labels, komposeLabel) {
err = oclient.ImageStreams(namespace).Delete(t.Name)
if err != nil {
return err
}
log.Infof("Successfully deleted ImageStream: %s", t.Name)
}
}
case *buildapi.BuildConfig: case *buildapi.BuildConfig:
err := oclient.BuildConfigs(namespace).Delete(t.Name) //options := api.ListOptions{LabelSelector: label}
buildConfig, err := oclient.BuildConfigs(namespace).List(options)
if err != nil { if err != nil {
return err return err
} }
log.Infof("Successfully deleted BuildConfig: %s", t.Name) for _, l := range buildConfig.Items {
if reflect.DeepEqual(l.Labels, komposeLabel) {
err := oclient.BuildConfigs(namespace).Delete(t.Name)
if err != nil {
return err
}
log.Infof("Successfully deleted BuildConfig: %s", t.Name)
}
}
case *deployapi.DeploymentConfig: case *deployapi.DeploymentConfig:
// delete deploymentConfig // delete deploymentConfig
dcreaper := deploymentconfigreaper.NewDeploymentConfigReaper(oclient, kclient) deploymentConfig, err := oclient.DeploymentConfigs(namespace).List(options)
err := dcreaper.Stop(namespace, t.Name, TIMEOUT*time.Second, nil)
if err != nil { if err != nil {
return err return err
} }
log.Infof("Successfully deleted DeploymentConfig: %s", t.Name) for _, l := range deploymentConfig.Items {
if reflect.DeepEqual(l.Labels, komposeLabel) {
dcreaper := deploymentconfigreaper.NewDeploymentConfigReaper(oclient, kclient)
err := dcreaper.Stop(namespace, t.Name, TIMEOUT*time.Second, nil)
if err != nil {
return err
}
log.Infof("Successfully deleted DeploymentConfig: %s", t.Name)
}
}
case *api.Service: case *api.Service:
//delete svc //delete svc
rpService, err := kubectl.ReaperFor(api.Kind("Service"), kclient) svc, err := kclient.Services(namespace).List(options)
if err != nil { if err != nil {
return err return err
} }
//FIXME: gracePeriod is nil for _, l := range svc.Items {
err = rpService.Stop(namespace, t.Name, TIMEOUT*time.Second, nil) if reflect.DeepEqual(l.Labels, komposeLabel) {
if err != nil { rpService, err := kubectl.ReaperFor(api.Kind("Service"), kclient)
return err if err != nil {
return err
}
//FIXME: gracePeriod is nil
err = rpService.Stop(namespace, t.Name, TIMEOUT*time.Second, nil)
if err != nil {
return err
}
log.Infof("Successfully deleted Service: %s", t.Name)
}
} }
log.Infof("Successfully deleted Service: %s", t.Name)
case *api.PersistentVolumeClaim: case *api.PersistentVolumeClaim:
// delete pvc // delete pvc
err = kclient.PersistentVolumeClaims(namespace).Delete(t.Name) pvc, err := kclient.PersistentVolumeClaims(namespace).List(options)
if err != nil { if err != nil {
return err return err
} }
log.Infof("Successfully deleted PersistentVolumeClaim: %s", t.Name) for _, l := range pvc.Items {
if reflect.DeepEqual(l.Labels, komposeLabel) {
err = kclient.PersistentVolumeClaims(namespace).Delete(t.Name)
if err != nil {
return err
}
log.Infof("Successfully deleted PersistentVolumeClaim: %s", t.Name)
}
}
case *routeapi.Route: case *routeapi.Route:
// delete route // delete route
err = oclient.Routes(namespace).Delete(t.Name) route, err := oclient.Routes(namespace).List(options)
if err != nil { if err != nil {
return err return err
} }
log.Infof("Successfully deleted Route: %s", t.Name) for _, l := range route.Items {
if reflect.DeepEqual(l.Labels, komposeLabel) {
err = oclient.Routes(namespace).Delete(t.Name)
if err != nil {
return err
}
log.Infof("Successfully deleted Route: %s", t.Name)
}
}
case *api.Pod: case *api.Pod:
rpPod, err := kubectl.ReaperFor(api.Kind("Pod"), kclient) //delete pods
pod, err := kclient.Pods(namespace).List(options)
if err != nil { if err != nil {
return err return err
} }
//FIXME: gracePeriod is nil for _, l := range pod.Items {
err = rpPod.Stop(namespace, t.Name, TIMEOUT*time.Second, nil) if reflect.DeepEqual(l.Labels, komposeLabel) {
if err != nil { rpPod, err := kubectl.ReaperFor(api.Kind("Pod"), kclient)
return err if err != nil {
return err
}
//FIXME: gracePeriod is nil
err = rpPod.Stop(namespace, t.Name, TIMEOUT*time.Second, nil)
if err != nil {
return err
}
log.Infof("Successfully deleted Pod: %s", t.Name)
}
} }
log.Infof("Successfully deleted Pod: %s", t.Name)
} }
} }
return nil return nil

View File

@ -37,6 +37,7 @@ import (
) )
const letterBytes = "abcdefghijklmnopqrstuvwxyz0123456789" const letterBytes = "abcdefghijklmnopqrstuvwxyz0123456789"
const Selector = "io.kompose.service"
// RandStringBytes generates randomly n-character string // RandStringBytes generates randomly n-character string
func RandStringBytes(n int) string { func RandStringBytes(n int) string {
@ -116,7 +117,7 @@ func isPath(substring string) bool {
// ConfigLabels configures label // ConfigLabels configures label
func ConfigLabels(name string) map[string]string { func ConfigLabels(name string) map[string]string {
return map[string]string{"service": name} return map[string]string{Selector: name}
} }
// ConfigAnnotations configures annotations // ConfigAnnotations configures annotations

View File

@ -10,7 +10,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"status": { "status": {
@ -36,7 +36,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -48,7 +48,7 @@
} }
], ],
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"status": { "status": {
@ -68,7 +68,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -104,7 +104,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {

View File

@ -3,33 +3,6 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": {}, "metadata": {},
"items": [ "items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "worker",
"creationTimestamp": null,
"labels": {
"service": "worker"
}
},
"spec": {
"ports": [
{
"name": "headless",
"port": 55555,
"targetPort": 0
}
],
"selector": {
"service": "worker"
},
"clusterIP": "None"
},
"status": {
"loadBalancer": {}
}
},
{ {
"kind": "Service", "kind": "Service",
"apiVersion": "v1", "apiVersion": "v1",
@ -37,7 +10,7 @@
"name": "db", "name": "db",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "db" "io.kompose.service": "db"
}, },
"annotations": { "annotations": {
"com.example.description": "Postgres Database" "com.example.description": "Postgres Database"
@ -52,7 +25,7 @@
} }
], ],
"selector": { "selector": {
"service": "db" "io.kompose.service": "db"
} }
}, },
"status": { "status": {
@ -66,7 +39,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -78,7 +51,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"status": { "status": {
@ -92,7 +65,7 @@
"name": "result", "name": "result",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "result" "io.kompose.service": "result"
} }
}, },
"spec": { "spec": {
@ -104,7 +77,7 @@
} }
], ],
"selector": { "selector": {
"service": "result" "io.kompose.service": "result"
} }
}, },
"status": { "status": {
@ -118,7 +91,7 @@
"name": "vote", "name": "vote",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "vote" "io.kompose.service": "vote"
}, },
"annotations": { "annotations": {
"com.example.description": "Vote" "com.example.description": "Vote"
@ -133,7 +106,7 @@
} }
], ],
"selector": { "selector": {
"service": "vote" "io.kompose.service": "vote"
} }
}, },
"status": { "status": {
@ -141,35 +114,31 @@
} }
}, },
{ {
"kind": "Deployment", "kind": "Service",
"apiVersion": "extensions/v1beta1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "worker", "name": "worker",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "worker"
}
}, },
"spec": { "spec": {
"replicas": 1, "ports": [
"template": { {
"metadata": { "name": "headless",
"creationTimestamp": null, "port": 55555,
"labels": { "targetPort": 0
"service": "worker"
}
},
"spec": {
"containers": [
{
"name": "worker",
"image": "docker/example-voting-app-worker",
"resources": {}
}
],
"restartPolicy": "Always"
} }
],
"selector": {
"io.kompose.service": "worker"
}, },
"strategy": {} "clusterIP": "None"
}, },
"status": {} "status": {
"loadBalancer": {}
}
}, },
{ {
"kind": "Deployment", "kind": "Deployment",
@ -187,7 +156,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "db" "io.kompose.service": "db"
} }
}, },
"spec": { "spec": {
@ -223,7 +192,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -259,7 +228,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "result" "io.kompose.service": "result"
} }
}, },
"spec": { "spec": {
@ -298,7 +267,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "vote" "io.kompose.service": "vote"
} }
}, },
"spec": { "spec": {
@ -320,6 +289,37 @@
"strategy": {} "strategy": {}
}, },
"status": {} "status": {}
},
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "worker",
"creationTimestamp": null
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "worker"
}
},
"spec": {
"containers": [
{
"name": "worker",
"image": "docker/example-voting-app-worker",
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
} }
] ]
} }

View File

@ -3,6 +3,33 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": {}, "metadata": {},
"items": [ "items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "base",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "base"
}
},
"spec": {
"ports": [
{
"name": "headless",
"port": 55555,
"targetPort": 0
}
],
"selector": {
"io.kompose.service": "base"
},
"clusterIP": "None"
},
"status": {
"loadBalancer": {}
}
},
{ {
"kind": "Deployment", "kind": "Deployment",
"apiVersion": "extensions/v1beta1", "apiVersion": "extensions/v1beta1",
@ -16,7 +43,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "base" "io.kompose.service": "base"
} }
}, },
"spec": { "spec": {
@ -39,33 +66,6 @@
"strategy": {} "strategy": {}
}, },
"status": {} "status": {}
},
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "base",
"creationTimestamp": null,
"labels": {
"service": "base"
}
},
"spec": {
"ports": [
{
"name": "headless",
"port": 55555,
"targetPort": 0
}
],
"selector": {
"service": "base"
},
"clusterIP": "None"
},
"status": {
"loadBalancer": {}
}
} }
] ]
} }

View File

@ -10,7 +10,7 @@
"name": "base", "name": "base",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "base" "io.kompose.service": "base"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "base" "io.kompose.service": "base"
}, },
"clusterIP": "None" "clusterIP": "None"
}, },
@ -37,7 +37,7 @@
"name": "base", "name": "base",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "base" "io.kompose.service": "base"
} }
}, },
"spec": { "spec": {
@ -65,13 +65,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "base" "io.kompose.service": "base"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "base" "io.kompose.service": "base"
} }
}, },
"spec": { "spec": {
@ -99,7 +99,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "base", "name": "base",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "base"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [

View File

@ -10,7 +10,7 @@
"name": "hygieia-api", "name": "hygieia-api",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-api" "io.kompose.service": "hygieia-api"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "hygieia-api" "io.kompose.service": "hygieia-api"
} }
}, },
"status": { "status": {
@ -36,7 +36,7 @@
"name": "hygieia-bitbucket-scm-collector", "name": "hygieia-bitbucket-scm-collector",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-bitbucket-scm-collector" "io.kompose.service": "hygieia-bitbucket-scm-collector"
} }
}, },
"spec": { "spec": {
@ -48,7 +48,7 @@
} }
], ],
"selector": { "selector": {
"service": "hygieia-bitbucket-scm-collector" "io.kompose.service": "hygieia-bitbucket-scm-collector"
}, },
"clusterIP": "None" "clusterIP": "None"
}, },
@ -63,7 +63,7 @@
"name": "hygieia-chat-ops-collector", "name": "hygieia-chat-ops-collector",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-chat-ops-collector" "io.kompose.service": "hygieia-chat-ops-collector"
} }
}, },
"spec": { "spec": {
@ -75,7 +75,7 @@
} }
], ],
"selector": { "selector": {
"service": "hygieia-chat-ops-collector" "io.kompose.service": "hygieia-chat-ops-collector"
}, },
"clusterIP": "None" "clusterIP": "None"
}, },
@ -90,7 +90,7 @@
"name": "hygieia-github-scm-collector", "name": "hygieia-github-scm-collector",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-github-scm-collector" "io.kompose.service": "hygieia-github-scm-collector"
} }
}, },
"spec": { "spec": {
@ -102,7 +102,7 @@
} }
], ],
"selector": { "selector": {
"service": "hygieia-github-scm-collector" "io.kompose.service": "hygieia-github-scm-collector"
}, },
"clusterIP": "None" "clusterIP": "None"
}, },
@ -117,7 +117,7 @@
"name": "hygieia-jenkins-build-collector", "name": "hygieia-jenkins-build-collector",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-jenkins-build-collector" "io.kompose.service": "hygieia-jenkins-build-collector"
} }
}, },
"spec": { "spec": {
@ -129,7 +129,7 @@
} }
], ],
"selector": { "selector": {
"service": "hygieia-jenkins-build-collector" "io.kompose.service": "hygieia-jenkins-build-collector"
}, },
"clusterIP": "None" "clusterIP": "None"
}, },
@ -144,7 +144,7 @@
"name": "hygieia-jenkins-cucumber-test-collector", "name": "hygieia-jenkins-cucumber-test-collector",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-jenkins-cucumber-test-collector" "io.kompose.service": "hygieia-jenkins-cucumber-test-collector"
} }
}, },
"spec": { "spec": {
@ -156,7 +156,7 @@
} }
], ],
"selector": { "selector": {
"service": "hygieia-jenkins-cucumber-test-collector" "io.kompose.service": "hygieia-jenkins-cucumber-test-collector"
}, },
"clusterIP": "None" "clusterIP": "None"
}, },
@ -171,7 +171,7 @@
"name": "hygieia-jira-feature-collector", "name": "hygieia-jira-feature-collector",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-jira-feature-collector" "io.kompose.service": "hygieia-jira-feature-collector"
} }
}, },
"spec": { "spec": {
@ -183,7 +183,7 @@
} }
], ],
"selector": { "selector": {
"service": "hygieia-jira-feature-collector" "io.kompose.service": "hygieia-jira-feature-collector"
}, },
"clusterIP": "None" "clusterIP": "None"
}, },
@ -198,7 +198,7 @@
"name": "hygieia-sonar-codequality-collector", "name": "hygieia-sonar-codequality-collector",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-sonar-codequality-collector" "io.kompose.service": "hygieia-sonar-codequality-collector"
} }
}, },
"spec": { "spec": {
@ -210,7 +210,7 @@
} }
], ],
"selector": { "selector": {
"service": "hygieia-sonar-codequality-collector" "io.kompose.service": "hygieia-sonar-codequality-collector"
}, },
"clusterIP": "None" "clusterIP": "None"
}, },
@ -225,7 +225,7 @@
"name": "hygieia-subversion-scm-collector", "name": "hygieia-subversion-scm-collector",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-subversion-scm-collector" "io.kompose.service": "hygieia-subversion-scm-collector"
} }
}, },
"spec": { "spec": {
@ -237,7 +237,7 @@
} }
], ],
"selector": { "selector": {
"service": "hygieia-subversion-scm-collector" "io.kompose.service": "hygieia-subversion-scm-collector"
}, },
"clusterIP": "None" "clusterIP": "None"
}, },
@ -252,7 +252,7 @@
"name": "hygieia-udeploy-collector", "name": "hygieia-udeploy-collector",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-udeploy-collector" "io.kompose.service": "hygieia-udeploy-collector"
} }
}, },
"spec": { "spec": {
@ -264,7 +264,7 @@
} }
], ],
"selector": { "selector": {
"service": "hygieia-udeploy-collector" "io.kompose.service": "hygieia-udeploy-collector"
}, },
"clusterIP": "None" "clusterIP": "None"
}, },
@ -279,7 +279,7 @@
"name": "hygieia-ui", "name": "hygieia-ui",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-ui" "io.kompose.service": "hygieia-ui"
} }
}, },
"spec": { "spec": {
@ -291,7 +291,7 @@
} }
], ],
"selector": { "selector": {
"service": "hygieia-ui" "io.kompose.service": "hygieia-ui"
} }
}, },
"status": { "status": {
@ -305,7 +305,7 @@
"name": "hygieia-versionone-collector", "name": "hygieia-versionone-collector",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-versionone-collector" "io.kompose.service": "hygieia-versionone-collector"
} }
}, },
"spec": { "spec": {
@ -317,7 +317,7 @@
} }
], ],
"selector": { "selector": {
"service": "hygieia-versionone-collector" "io.kompose.service": "hygieia-versionone-collector"
}, },
"clusterIP": "None" "clusterIP": "None"
}, },
@ -332,7 +332,7 @@
"name": "mongodb", "name": "mongodb",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "mongodb" "io.kompose.service": "mongodb"
} }
}, },
"spec": { "spec": {
@ -344,7 +344,7 @@
} }
], ],
"selector": { "selector": {
"service": "mongodb" "io.kompose.service": "mongodb"
} }
}, },
"status": { "status": {
@ -364,7 +364,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-api" "io.kompose.service": "hygieia-api"
} }
}, },
"spec": { "spec": {
@ -408,7 +408,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "hygieia-api-claim0", "name": "hygieia-api-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "hygieia-api-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [
@ -435,7 +438,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-bitbucket-scm-collector" "io.kompose.service": "hygieia-bitbucket-scm-collector"
} }
}, },
"spec": { "spec": {
@ -474,7 +477,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "hygieia-bitbucket-scm-collector-claim0", "name": "hygieia-bitbucket-scm-collector-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "hygieia-bitbucket-scm-collector-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [
@ -501,7 +507,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-chat-ops-collector" "io.kompose.service": "hygieia-chat-ops-collector"
} }
}, },
"spec": { "spec": {
@ -540,7 +546,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "hygieia-chat-ops-collector-claim0", "name": "hygieia-chat-ops-collector-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "hygieia-chat-ops-collector-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [
@ -567,7 +576,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-github-scm-collector" "io.kompose.service": "hygieia-github-scm-collector"
} }
}, },
"spec": { "spec": {
@ -606,7 +615,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "hygieia-github-scm-collector-claim0", "name": "hygieia-github-scm-collector-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "hygieia-github-scm-collector-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [
@ -633,7 +645,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-jenkins-build-collector" "io.kompose.service": "hygieia-jenkins-build-collector"
} }
}, },
"spec": { "spec": {
@ -672,7 +684,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "hygieia-jenkins-build-collector-claim0", "name": "hygieia-jenkins-build-collector-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "hygieia-jenkins-build-collector-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [
@ -699,7 +714,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-jenkins-cucumber-test-collector" "io.kompose.service": "hygieia-jenkins-cucumber-test-collector"
} }
}, },
"spec": { "spec": {
@ -738,7 +753,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "hygieia-jenkins-cucumber-test-collector-claim0", "name": "hygieia-jenkins-cucumber-test-collector-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "hygieia-jenkins-cucumber-test-collector-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [
@ -765,7 +783,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-jira-feature-collector" "io.kompose.service": "hygieia-jira-feature-collector"
} }
}, },
"spec": { "spec": {
@ -814,7 +832,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "hygieia-jira-feature-collector-claim0", "name": "hygieia-jira-feature-collector-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "hygieia-jira-feature-collector-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [
@ -841,7 +862,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-sonar-codequality-collector" "io.kompose.service": "hygieia-sonar-codequality-collector"
} }
}, },
"spec": { "spec": {
@ -880,7 +901,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "hygieia-sonar-codequality-collector-claim0", "name": "hygieia-sonar-codequality-collector-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "hygieia-sonar-codequality-collector-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [
@ -907,7 +931,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-subversion-scm-collector" "io.kompose.service": "hygieia-subversion-scm-collector"
} }
}, },
"spec": { "spec": {
@ -946,7 +970,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "hygieia-subversion-scm-collector-claim0", "name": "hygieia-subversion-scm-collector-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "hygieia-subversion-scm-collector-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [
@ -973,7 +1000,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-udeploy-collector" "io.kompose.service": "hygieia-udeploy-collector"
} }
}, },
"spec": { "spec": {
@ -1026,7 +1053,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "hygieia-udeploy-collector-claim0", "name": "hygieia-udeploy-collector-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "hygieia-udeploy-collector-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [
@ -1053,7 +1083,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-ui" "io.kompose.service": "hygieia-ui"
} }
}, },
"spec": { "spec": {
@ -1089,7 +1119,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "hygieia-versionone-collector" "io.kompose.service": "hygieia-versionone-collector"
} }
}, },
"spec": { "spec": {
@ -1128,7 +1158,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "hygieia-versionone-collector-claim0", "name": "hygieia-versionone-collector-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "hygieia-versionone-collector-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [
@ -1155,7 +1188,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "mongodb" "io.kompose.service": "mongodb"
} }
}, },
"spec": { "spec": {
@ -1203,7 +1236,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "mongodb-claim0", "name": "mongodb-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "mongodb-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [

View File

@ -10,7 +10,7 @@
"name": "etherpad", "name": "etherpad",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "etherpad" "io.kompose.service": "etherpad"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "etherpad" "io.kompose.service": "etherpad"
} }
}, },
"status": { "status": {
@ -36,7 +36,7 @@
"name": "mariadb", "name": "mariadb",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "mariadb" "io.kompose.service": "mariadb"
} }
}, },
"spec": { "spec": {
@ -48,7 +48,7 @@
} }
], ],
"selector": { "selector": {
"service": "mariadb" "io.kompose.service": "mariadb"
} }
}, },
"status": { "status": {
@ -68,7 +68,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "etherpad" "io.kompose.service": "etherpad"
} }
}, },
"spec": { "spec": {
@ -82,6 +82,10 @@
} }
], ],
"env": [ "env": [
{
"name": "DB_USER",
"value": "etherpad"
},
{ {
"name": "DB_DBID", "name": "DB_DBID",
"value": "etherpad" "value": "etherpad"
@ -97,10 +101,6 @@
{ {
"name": "DB_PORT", "name": "DB_PORT",
"value": "3306" "value": "3306"
},
{
"name": "DB_USER",
"value": "etherpad"
} }
], ],
"resources": {} "resources": {}
@ -126,7 +126,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "mariadb" "io.kompose.service": "mariadb"
} }
}, },
"spec": { "spec": {
@ -178,8 +178,8 @@
} }
}, },
"strategy": { "strategy": {
"type": "Recreate" "type": "Recreate"
} }
}, },
"status": {} "status": {}
}, },
@ -188,7 +188,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "mariadb-claim0", "name": "mariadb-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "mariadb-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [

View File

@ -10,7 +10,7 @@
"name": "etherpad", "name": "etherpad",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "etherpad" "io.kompose.service": "etherpad"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "etherpad" "io.kompose.service": "etherpad"
} }
}, },
"status": { "status": {
@ -36,7 +36,7 @@
"name": "mariadb", "name": "mariadb",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "mariadb" "io.kompose.service": "mariadb"
} }
}, },
"spec": { "spec": {
@ -48,7 +48,7 @@
} }
], ],
"selector": { "selector": {
"service": "mariadb" "io.kompose.service": "mariadb"
} }
}, },
"status": { "status": {
@ -62,7 +62,7 @@
"name": "etherpad", "name": "etherpad",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "etherpad" "io.kompose.service": "etherpad"
} }
}, },
"spec": { "spec": {
@ -90,13 +90,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "etherpad" "io.kompose.service": "etherpad"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "etherpad" "io.kompose.service": "etherpad"
} }
}, },
"spec": { "spec": {
@ -110,14 +110,6 @@
} }
], ],
"env": [ "env": [
{
"name": "DB_PORT",
"value": "3306"
},
{
"name": "DB_USER",
"value": "etherpad"
},
{ {
"name": "DB_DBID", "name": "DB_DBID",
"value": "etherpad" "value": "etherpad"
@ -129,6 +121,14 @@
{ {
"name": "DB_PASS", "name": "DB_PASS",
"value": "etherpad" "value": "etherpad"
},
{
"name": "DB_PORT",
"value": "3306"
},
{
"name": "DB_USER",
"value": "etherpad"
} }
], ],
"resources": {} "resources": {}
@ -145,7 +145,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "etherpad", "name": "etherpad",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "etherpad"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [
@ -172,13 +175,13 @@
"name": "mariadb", "name": "mariadb",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "mariadb" "io.kompose.service": "mariadb"
} }
}, },
"spec": { "spec": {
"strategy": { "strategy": {
"resources": {}, "type": "Recreate",
"type": "Recreate" "resources": {}
}, },
"triggers": [ "triggers": [
{ {
@ -201,13 +204,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "mariadb" "io.kompose.service": "mariadb"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "mariadb" "io.kompose.service": "mariadb"
} }
}, },
"spec": { "spec": {
@ -229,14 +232,6 @@
} }
], ],
"env": [ "env": [
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "etherpad"
},
{
"name": "MYSQL_USER",
"value": "etherpad"
},
{ {
"name": "MYSQL_DATABASE", "name": "MYSQL_DATABASE",
"value": "etherpad" "value": "etherpad"
@ -244,6 +239,14 @@
{ {
"name": "MYSQL_PASSWORD", "name": "MYSQL_PASSWORD",
"value": "etherpad" "value": "etherpad"
},
{
"name": "MYSQL_ROOT_PASSWORD",
"value": "etherpad"
},
{
"name": "MYSQL_USER",
"value": "etherpad"
} }
], ],
"resources": {}, "resources": {},
@ -266,7 +269,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "mariadb", "name": "mariadb",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "mariadb"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [
@ -291,7 +297,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "mariadb-claim0", "name": "mariadb-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "mariadb-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [

View File

@ -10,7 +10,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"status": { "status": {
@ -36,7 +36,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
}, },
"annotations": { "annotations": {
"kompose.service.expose": "batman.example.com" "kompose.service.expose": "batman.example.com"
@ -56,7 +56,7 @@
} }
], ],
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"status": { "status": {
@ -76,7 +76,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -115,7 +115,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {

View File

@ -3,6 +3,32 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": {}, "metadata": {},
"items": [ "items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"io.kompose.service": "redis"
}
},
"status": {
"loadBalancer": {}
}
},
{ {
"kind": "Service", "kind": "Service",
"apiVersion": "v1", "apiVersion": "v1",
@ -10,7 +36,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
}, },
"annotations": { "annotations": {
"kompose.service.expose": "batman.example.com" "kompose.service.expose": "batman.example.com"
@ -25,7 +51,7 @@
} }
], ],
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"status": { "status": {
@ -33,30 +59,40 @@
} }
}, },
{ {
"kind": "Service", "kind": "Deployment",
"apiVersion": "v1", "apiVersion": "extensions/v1beta1",
"metadata": { "metadata": {
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null
"labels": {
"service": "redis"
}
}, },
"spec": { "spec": {
"ports": [ "replicas": 1,
{ "template": {
"name": "6379", "metadata": {
"port": 6379, "creationTimestamp": null,
"targetPort": 6379 "labels": {
"io.kompose.service": "redis"
}
},
"spec": {
"containers": [
{
"name": "redis",
"image": "redis:3.0",
"ports": [
{
"containerPort": 6379
}
],
"resources": {}
}
],
"restartPolicy": "Always"
} }
], },
"selector": { "strategy": {}
"service": "redis"
}
}, },
"status": { "status": {}
"loadBalancer": {}
}
}, },
{ {
"kind": "Deployment", "kind": "Deployment",
@ -74,7 +110,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -124,42 +160,6 @@
"status": { "status": {
"loadBalancer": {} "loadBalancer": {}
} }
},
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "redis",
"creationTimestamp": null
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"containers": [
{
"name": "redis",
"image": "redis:3.0",
"ports": [
{
"containerPort": 6379
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
} }
] ]
} }

View File

@ -10,7 +10,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"status": { "status": {
@ -36,7 +36,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
}, },
"annotations": { "annotations": {
"kompose.service.expose": "True" "kompose.service.expose": "True"
@ -56,7 +56,7 @@
} }
], ],
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"status": { "status": {
@ -76,7 +76,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -115,7 +115,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {

View File

@ -10,7 +10,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"status": { "status": {
@ -36,7 +36,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
}, },
"annotations": { "annotations": {
"kompose.service.expose": "True" "kompose.service.expose": "True"
@ -51,7 +51,7 @@
} }
], ],
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"status": { "status": {
@ -71,7 +71,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -110,7 +110,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {

View File

@ -3,6 +3,32 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": {}, "metadata": {},
"items": [ "items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"io.kompose.service": "redis"
}
},
"status": {
"loadBalancer": {}
}
},
{ {
"kind": "Service", "kind": "Service",
"apiVersion": "v1", "apiVersion": "v1",
@ -10,7 +36,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
}, },
"annotations": { "annotations": {
"kompose.service.expose": "batman.example.com" "kompose.service.expose": "batman.example.com"
@ -30,39 +56,104 @@
} }
], ],
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis"
} }
}, },
"status": { "status": {
"loadBalancer": {} "loadBalancer": {}
} }
}, },
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"redis"
],
"from": {
"kind": "ImageStreamTag",
"name": "redis:3.0"
}
}
}
],
"replicas": 1,
"test": false,
"selector": {
"io.kompose.service": "redis"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
},
"spec": {
"containers": [
{
"name": "redis",
"image": " ",
"ports": [
{
"containerPort": 6379
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
},
"spec": {
"tags": [
{
"name": "3.0",
"annotations": null,
"from": {
"kind": "DockerImage",
"name": "redis:3.0"
},
"generation": null,
"importPolicy": {}
}
]
},
"status": {
"dockerImageRepository": ""
}
},
{ {
"kind": "DeploymentConfig", "kind": "DeploymentConfig",
"apiVersion": "v1", "apiVersion": "v1",
@ -70,7 +161,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
}, },
"annotations": { "annotations": {
"kompose.service.expose": "batman.example.com" "kompose.service.expose": "batman.example.com"
@ -101,13 +192,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -137,7 +228,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "web", "name": "web",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "web"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [
@ -178,94 +272,6 @@
"status": { "status": {
"ingress": null "ingress": null
} }
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"redis"
],
"from": {
"kind": "ImageStreamTag",
"name": "redis:3.0"
}
}
}
],
"replicas": 1,
"test": false,
"selector": {
"service": "redis"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"containers": [
{
"name": "redis",
"image": " ",
"ports": [
{
"containerPort": 6379
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null
},
"spec": {
"tags": [
{
"name": "3.0",
"annotations": null,
"from": {
"kind": "DockerImage",
"name": "redis:3.0"
},
"generation": null,
"importPolicy": {}
}
]
},
"status": {
"dockerImageRepository": ""
}
} }
] ]
} }

View File

@ -10,7 +10,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"status": { "status": {
@ -36,7 +36,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
}, },
"annotations": { "annotations": {
"kompose.service.expose": "batman.example.com" "kompose.service.expose": "batman.example.com"
@ -51,7 +51,7 @@
} }
], ],
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"status": { "status": {
@ -65,7 +65,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -93,13 +93,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -126,7 +126,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "redis", "name": "redis",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [
@ -153,7 +156,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
}, },
"annotations": { "annotations": {
"kompose.service.expose": "batman.example.com" "kompose.service.expose": "batman.example.com"
@ -184,13 +187,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -217,7 +220,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "web", "name": "web",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "web"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [

View File

@ -10,7 +10,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"status": { "status": {
@ -36,7 +36,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
}, },
"annotations": { "annotations": {
"kompose.service.expose": "True" "kompose.service.expose": "True"
@ -56,7 +56,7 @@
} }
], ],
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"status": { "status": {
@ -70,7 +70,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -98,13 +98,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -131,7 +131,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "redis", "name": "redis",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [
@ -158,7 +161,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
}, },
"annotations": { "annotations": {
"kompose.service.expose": "True" "kompose.service.expose": "True"
@ -189,13 +192,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -225,7 +228,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "web", "name": "web",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "web"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [

View File

@ -10,7 +10,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"status": { "status": {
@ -36,7 +36,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
}, },
"annotations": { "annotations": {
"kompose.service.expose": "True" "kompose.service.expose": "True"
@ -51,7 +51,7 @@
} }
], ],
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"status": { "status": {
@ -65,7 +65,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -93,13 +93,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -126,7 +126,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "redis", "name": "redis",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [
@ -153,7 +156,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
}, },
"annotations": { "annotations": {
"kompose.service.expose": "True" "kompose.service.expose": "True"
@ -184,13 +187,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -217,7 +220,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "web", "name": "web",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "web"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [

View File

@ -3,6 +3,170 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": {}, "metadata": {},
"items": [ "items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "gitlab",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "gitlab"
}
},
"spec": {
"ports": [
{
"name": "30000",
"port": 30000,
"targetPort": 80
},
{
"name": "30001",
"port": 30001,
"targetPort": 443
},
{
"name": "30002",
"port": 30002,
"targetPort": 22
}
],
"selector": {
"io.kompose.service": "gitlab"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "postgresql",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "postgresql"
}
},
"spec": {
"ports": [
{
"name": "5432",
"port": 5432,
"targetPort": 5432
}
],
"selector": {
"io.kompose.service": "postgresql"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"io.kompose.service": "redis"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "gitlab",
"creationTimestamp": null
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "gitlab"
}
},
"spec": {
"containers": [
{
"name": "gitlab",
"image": "swordphilic/gitlab",
"ports": [
{
"containerPort": 80
},
{
"containerPort": 443
},
{
"containerPort": 22
}
],
"env": [
{
"name": "REDIS_PORT",
"value": "6379"
},
{
"name": "DB_HOST",
"value": "postgresql"
},
{
"name": "DB_NAME",
"value": "gitlab"
},
{
"name": "DB_PASS",
"value": "gitlab"
},
{
"name": "DB_PORT",
"value": "5432"
},
{
"name": "DB_TYPE",
"value": "postgres"
},
{
"name": "DB_USER",
"value": "gitlab"
},
{
"name": "REDIS_HOST",
"value": "redis"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
},
{ {
"kind": "Deployment", "kind": "Deployment",
"apiVersion": "extensions/v1beta1", "apiVersion": "extensions/v1beta1",
@ -16,7 +180,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "postgresql" "io.kompose.service": "postgresql"
} }
}, },
"spec": { "spec": {
@ -53,32 +217,6 @@
}, },
"status": {} "status": {}
}, },
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "postgresql",
"creationTimestamp": null,
"labels": {
"service": "postgresql"
}
},
"spec": {
"ports": [
{
"name": "5432",
"port": 5432,
"targetPort": 5432
}
],
"selector": {
"service": "postgresql"
}
},
"status": {
"loadBalancer": {}
}
},
{ {
"kind": "Deployment", "kind": "Deployment",
"apiVersion": "extensions/v1beta1", "apiVersion": "extensions/v1beta1",
@ -92,7 +230,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -114,144 +252,6 @@
"strategy": {} "strategy": {}
}, },
"status": {} "status": {}
},
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "gitlab",
"creationTimestamp": null
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "gitlab"
}
},
"spec": {
"containers": [
{
"name": "gitlab",
"image": "swordphilic/gitlab",
"ports": [
{
"containerPort": 80
},
{
"containerPort": 443
},
{
"containerPort": 22
}
],
"env": [
{
"name": "DB_TYPE",
"value": "postgres"
},
{
"name": "DB_USER",
"value": "gitlab"
},
{
"name": "REDIS_HOST",
"value": "redis"
},
{
"name": "REDIS_PORT",
"value": "6379"
},
{
"name": "DB_HOST",
"value": "postgresql"
},
{
"name": "DB_NAME",
"value": "gitlab"
},
{
"name": "DB_PASS",
"value": "gitlab"
},
{
"name": "DB_PORT",
"value": "5432"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
},
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "gitlab",
"creationTimestamp": null,
"labels": {
"service": "gitlab"
}
},
"spec": {
"ports": [
{
"name": "30000",
"port": 30000,
"targetPort": 80
},
{
"name": "30001",
"port": 30001,
"targetPort": 443
},
{
"name": "30002",
"port": 30002,
"targetPort": 22
}
],
"selector": {
"service": "gitlab"
}
},
"status": {
"loadBalancer": {}
}
} }
] ]
} }

View File

@ -3,6 +3,58 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": {}, "metadata": {},
"items": [ "items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "postgresql",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "postgresql"
}
},
"spec": {
"ports": [
{
"name": "5432",
"port": 5432,
"targetPort": 5432
}
],
"selector": {
"io.kompose.service": "postgresql"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"io.kompose.service": "redis"
}
},
"status": {
"loadBalancer": {}
}
},
{ {
"kind": "Service", "kind": "Service",
"apiVersion": "v1", "apiVersion": "v1",
@ -10,7 +62,7 @@
"name": "gitlab", "name": "gitlab",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "gitlab" "io.kompose.service": "gitlab"
} }
}, },
"spec": { "spec": {
@ -32,193 +84,13 @@
} }
], ],
"selector": { "selector": {
"service": "gitlab" "io.kompose.service": "gitlab"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "postgresql",
"creationTimestamp": null,
"labels": {
"service": "postgresql"
}
},
"spec": {
"ports": [
{
"name": "5432",
"port": 5432,
"targetPort": 5432
}
],
"selector": {
"service": "postgresql"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis"
} }
}, },
"status": { "status": {
"loadBalancer": {} "loadBalancer": {}
} }
}, },
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "gitlab",
"creationTimestamp": null,
"labels": {
"service": "gitlab"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"gitlab"
],
"from": {
"kind": "ImageStreamTag",
"name": "gitlab:latest"
}
}
}
],
"replicas": 1,
"test": false,
"selector": {
"service": "gitlab"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "gitlab"
}
},
"spec": {
"containers": [
{
"name": "gitlab",
"image": " ",
"ports": [
{
"containerPort": 80
},
{
"containerPort": 443
},
{
"containerPort": 22
}
],
"env": [
{
"name": "DB_NAME",
"value": "gitlab"
},
{
"name": "DB_PASS",
"value": "gitlab"
},
{
"name": "DB_PORT",
"value": "5432"
},
{
"name": "DB_TYPE",
"value": "postgres"
},
{
"name": "DB_USER",
"value": "gitlab"
},
{
"name": "REDIS_HOST",
"value": "redis"
},
{
"name": "REDIS_PORT",
"value": "6379"
},
{
"name": "DB_HOST",
"value": "postgresql"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "gitlab",
"creationTimestamp": null
},
"spec": {
"tags": [
{
"name": "latest",
"annotations": null,
"from": {
"kind": "DockerImage",
"name": "swordphilic/gitlab"
},
"generation": null,
"importPolicy": {}
}
]
},
"status": {
"dockerImageRepository": ""
}
},
{ {
"kind": "DeploymentConfig", "kind": "DeploymentConfig",
"apiVersion": "v1", "apiVersion": "v1",
@ -226,7 +98,7 @@
"name": "postgresql", "name": "postgresql",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "postgresql" "io.kompose.service": "postgresql"
} }
}, },
"spec": { "spec": {
@ -254,13 +126,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "postgresql" "io.kompose.service": "postgresql"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "postgresql" "io.kompose.service": "postgresql"
} }
}, },
"spec": { "spec": {
@ -301,7 +173,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "postgresql", "name": "postgresql",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "postgresql"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [
@ -328,7 +203,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -356,13 +231,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -389,7 +264,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "redis", "name": "redis",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [
@ -408,6 +286,137 @@
"status": { "status": {
"dockerImageRepository": "" "dockerImageRepository": ""
} }
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "gitlab",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "gitlab"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"gitlab"
],
"from": {
"kind": "ImageStreamTag",
"name": "gitlab:latest"
}
}
}
],
"replicas": 1,
"test": false,
"selector": {
"io.kompose.service": "gitlab"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "gitlab"
}
},
"spec": {
"containers": [
{
"name": "gitlab",
"image": " ",
"ports": [
{
"containerPort": 80
},
{
"containerPort": 443
},
{
"containerPort": 22
}
],
"env": [
{
"name": "DB_TYPE",
"value": "postgres"
},
{
"name": "DB_USER",
"value": "gitlab"
},
{
"name": "REDIS_HOST",
"value": "redis"
},
{
"name": "REDIS_PORT",
"value": "6379"
},
{
"name": "DB_HOST",
"value": "postgresql"
},
{
"name": "DB_NAME",
"value": "gitlab"
},
{
"name": "DB_PASS",
"value": "gitlab"
},
{
"name": "DB_PORT",
"value": "5432"
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "gitlab",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "gitlab"
}
},
"spec": {
"tags": [
{
"name": "latest",
"annotations": null,
"from": {
"kind": "DockerImage",
"name": "swordphilic/gitlab"
},
"generation": null,
"importPolicy": {}
}
]
},
"status": {
"dockerImageRepository": ""
}
} }
] ]
} }

View File

@ -10,7 +10,7 @@
"name": "frontend", "name": "frontend",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "frontend" "io.kompose.service": "frontend"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "frontend" "io.kompose.service": "frontend"
} }
}, },
"status": { "status": {
@ -36,7 +36,7 @@
"name": "redis-master", "name": "redis-master",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis-master" "io.kompose.service": "redis-master"
} }
}, },
"spec": { "spec": {
@ -48,7 +48,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis-master" "io.kompose.service": "redis-master"
} }
}, },
"status": { "status": {
@ -62,7 +62,7 @@
"name": "redis-slave", "name": "redis-slave",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis-slave" "io.kompose.service": "redis-slave"
} }
}, },
"spec": { "spec": {
@ -74,7 +74,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis-slave" "io.kompose.service": "redis-slave"
} }
}, },
"status": { "status": {
@ -94,7 +94,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "frontend" "io.kompose.service": "frontend"
} }
}, },
"spec": { "spec": {
@ -108,14 +108,6 @@
} }
], ],
"env": [ "env": [
{
"name": "GET_HOSTS_FROM",
"value": "dns"
},
{
"name": "RACK_ENV",
"value": "development"
},
{ {
"name": "SESSION_SECRET", "name": "SESSION_SECRET",
"value": "session" "value": "session"
@ -123,6 +115,14 @@
{ {
"name": "SHOW", "name": "SHOW",
"value": "true" "value": "true"
},
{
"name": "GET_HOSTS_FROM",
"value": "dns"
},
{
"name": "RACK_ENV",
"value": "development"
} }
], ],
"resources": {} "resources": {}
@ -148,7 +148,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis-master" "io.kompose.service": "redis-master"
} }
}, },
"spec": { "spec": {
@ -184,7 +184,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis-slave" "io.kompose.service": "redis-slave"
} }
}, },
"spec": { "spec": {

View File

@ -10,7 +10,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -28,7 +28,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"status": { "status": {
@ -48,7 +48,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {

View File

@ -10,7 +10,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -28,7 +28,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"status": { "status": {
@ -48,7 +48,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {

View File

@ -10,7 +10,7 @@
"name": "etherpad", "name": "etherpad",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "etherpad" "io.kompose.service": "etherpad"
} }
}, },
"spec": { "spec": {
@ -27,7 +27,7 @@
} }
], ],
"selector": { "selector": {
"service": "etherpad" "io.kompose.service": "etherpad"
} }
}, },
"status": { "status": {
@ -41,7 +41,7 @@
"name": "mariadb", "name": "mariadb",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "mariadb" "io.kompose.service": "mariadb"
} }
}, },
"spec": { "spec": {
@ -58,7 +58,7 @@
} }
], ],
"selector": { "selector": {
"service": "mariadb" "io.kompose.service": "mariadb"
} }
}, },
"status": { "status": {
@ -78,7 +78,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "etherpad" "io.kompose.service": "etherpad"
} }
}, },
"spec": { "spec": {
@ -95,10 +95,6 @@
} }
], ],
"env": [ "env": [
{
"name": "DB_USER",
"value": "openshift"
},
{ {
"name": "DB_DBID", "name": "DB_DBID",
"value": "openshift" "value": "openshift"
@ -114,6 +110,10 @@
{ {
"name": "DB_PORT", "name": "DB_PORT",
"value": "openshift" "value": "openshift"
},
{
"name": "DB_USER",
"value": "openshift"
} }
], ],
"resources": {} "resources": {}
@ -139,7 +139,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "mariadb" "io.kompose.service": "mariadb"
} }
}, },
"spec": { "spec": {
@ -170,10 +170,6 @@
} }
], ],
"env": [ "env": [
{
"name": "MYSQL_PASSWORD",
"value": "openshift"
},
{ {
"name": "MYSQL_ROOT_PASSWORD", "name": "MYSQL_ROOT_PASSWORD",
"value": "openshift" "value": "openshift"
@ -185,6 +181,10 @@
{ {
"name": "MYSQL_DATABASE", "name": "MYSQL_DATABASE",
"value": "openshift" "value": "openshift"
},
{
"name": "MYSQL_PASSWORD",
"value": "openshift"
} }
], ],
"resources": {}, "resources": {},
@ -204,8 +204,8 @@
} }
}, },
"strategy": { "strategy": {
"type": "Recreate" "type": "Recreate"
} }
}, },
"status": {} "status": {}
}, },
@ -214,7 +214,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "mariadb-claim0", "name": "mariadb-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "mariadb-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [
@ -233,7 +236,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "mariadb-claim1", "name": "mariadb-claim1",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "mariadb-claim1"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [

View File

@ -10,7 +10,7 @@
"name": "etherpad", "name": "etherpad",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "etherpad" "io.kompose.service": "etherpad"
} }
}, },
"spec": { "spec": {
@ -27,7 +27,7 @@
} }
], ],
"selector": { "selector": {
"service": "etherpad" "io.kompose.service": "etherpad"
} }
}, },
"status": { "status": {
@ -41,7 +41,7 @@
"name": "mariadb", "name": "mariadb",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "mariadb" "io.kompose.service": "mariadb"
} }
}, },
"spec": { "spec": {
@ -58,7 +58,7 @@
} }
], ],
"selector": { "selector": {
"service": "mariadb" "io.kompose.service": "mariadb"
} }
}, },
"status": { "status": {
@ -72,7 +72,7 @@
"name": "etherpad", "name": "etherpad",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "etherpad" "io.kompose.service": "etherpad"
} }
}, },
"spec": { "spec": {
@ -100,13 +100,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "etherpad" "io.kompose.service": "etherpad"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "etherpad" "io.kompose.service": "etherpad"
} }
}, },
"spec": { "spec": {
@ -123,6 +123,14 @@
} }
], ],
"env": [ "env": [
{
"name": "DB_PORT",
"value": "openshift"
},
{
"name": "DB_USER",
"value": "openshift"
},
{ {
"name": "DB_DBID", "name": "DB_DBID",
"value": "openshift" "value": "openshift"
@ -134,14 +142,6 @@
{ {
"name": "DB_PASS", "name": "DB_PASS",
"value": "openshift" "value": "openshift"
},
{
"name": "DB_PORT",
"value": "openshift"
},
{
"name": "DB_USER",
"value": "openshift"
} }
], ],
"resources": {} "resources": {}
@ -158,7 +158,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "etherpad", "name": "etherpad",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "etherpad"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [
@ -185,12 +188,12 @@
"name": "mariadb", "name": "mariadb",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "mariadb" "io.kompose.service": "mariadb"
} }
}, },
"spec": { "spec": {
"strategy": { "strategy": {
"type": "Recreate", "type": "Recreate",
"resources": {} "resources": {}
}, },
"triggers": [ "triggers": [
@ -214,13 +217,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "mariadb" "io.kompose.service": "mariadb"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "mariadb" "io.kompose.service": "mariadb"
} }
}, },
"spec": { "spec": {
@ -251,10 +254,6 @@
} }
], ],
"env": [ "env": [
{
"name": "MYSQL_DATABASE",
"value": "openshift"
},
{ {
"name": "MYSQL_PASSWORD", "name": "MYSQL_PASSWORD",
"value": "openshift" "value": "openshift"
@ -266,6 +265,10 @@
{ {
"name": "MYSQL_USER", "name": "MYSQL_USER",
"value": "openshift" "value": "openshift"
},
{
"name": "MYSQL_DATABASE",
"value": "openshift"
} }
], ],
"resources": {}, "resources": {},
@ -292,7 +295,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "mariadb", "name": "mariadb",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "mariadb"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [
@ -317,7 +323,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "mariadb-claim0", "name": "mariadb-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "mariadb-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [
@ -336,7 +345,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "mariadb-claim1", "name": "mariadb-claim1",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "mariadb-claim1"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [

View File

@ -4,48 +4,39 @@
"metadata": {}, "metadata": {},
"items": [ "items": [
{ {
"kind": "Deployment", "kind": "Service",
"apiVersion": "extensions/v1beta1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "node2", "name": "nginx",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "nginx"
}
}, },
"spec": { "spec": {
"replicas": 1, "ports": [
"template": { {
"metadata": { "name": "80",
"creationTimestamp": null, "port": 80,
"labels": { "targetPort": 80
"service": "node2"
}
},
"spec": {
"containers": [
{
"name": "node2",
"ports": [
{
"containerPort": 8080
}
],
"resources": {}
}
],
"restartPolicy": "Always"
} }
}, ],
"strategy": {} "selector": {
"io.kompose.service": "nginx"
}
}, },
"status": {} "status": {
"loadBalancer": {}
}
}, },
{ {
"kind": "Service", "kind": "Service",
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "node2", "name": "node1",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "node2" "io.kompose.service": "node1"
} }
}, },
"spec": { "spec": {
@ -57,56 +48,21 @@
} }
], ],
"selector": { "selector": {
"service": "node2" "io.kompose.service": "node1"
} }
}, },
"status": { "status": {
"loadBalancer": {} "loadBalancer": {}
} }
}, },
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "node3",
"creationTimestamp": null
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "node3"
}
},
"spec": {
"containers": [
{
"name": "node3",
"ports": [
{
"containerPort": 8080
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
},
{ {
"kind": "Service", "kind": "Service",
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "node3", "name": "node2",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "node3" "io.kompose.service": "node2"
} }
}, },
"spec": { "spec": {
@ -118,7 +74,7 @@
} }
], ],
"selector": { "selector": {
"service": "node3" "io.kompose.service": "node2"
} }
}, },
"status": { "status": {
@ -126,40 +82,30 @@
} }
}, },
{ {
"kind": "Deployment", "kind": "Service",
"apiVersion": "extensions/v1beta1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "redis", "name": "node3",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "node3"
}
}, },
"spec": { "spec": {
"replicas": 1, "ports": [
"template": { {
"metadata": { "name": "8080",
"creationTimestamp": null, "port": 8080,
"labels": { "targetPort": 8080
"service": "redis"
}
},
"spec": {
"containers": [
{
"name": "redis",
"image": "redis",
"ports": [
{
"containerPort": 6379
}
],
"resources": {}
}
],
"restartPolicy": "Always"
} }
}, ],
"strategy": {} "selector": {
"io.kompose.service": "node3"
}
}, },
"status": {} "status": {
"loadBalancer": {}
}
}, },
{ {
"kind": "Service", "kind": "Service",
@ -168,7 +114,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -180,7 +126,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"status": { "status": {
@ -200,7 +146,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "nginx" "io.kompose.service": "nginx"
} }
}, },
"spec": { "spec": {
@ -222,32 +168,6 @@
}, },
"status": {} "status": {}
}, },
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "nginx",
"creationTimestamp": null,
"labels": {
"service": "nginx"
}
},
"spec": {
"ports": [
{
"name": "80",
"port": 80,
"targetPort": 80
}
],
"selector": {
"service": "nginx"
}
},
"status": {
"loadBalancer": {}
}
},
{ {
"kind": "Deployment", "kind": "Deployment",
"apiVersion": "extensions/v1beta1", "apiVersion": "extensions/v1beta1",
@ -261,7 +181,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "node1" "io.kompose.service": "node1"
} }
}, },
"spec": { "spec": {
@ -284,30 +204,110 @@
"status": {} "status": {}
}, },
{ {
"kind": "Service", "kind": "Deployment",
"apiVersion": "v1", "apiVersion": "extensions/v1beta1",
"metadata": { "metadata": {
"name": "node1", "name": "node2",
"creationTimestamp": null, "creationTimestamp": null
"labels": {
"service": "node1"
}
}, },
"spec": { "spec": {
"ports": [ "replicas": 1,
{ "template": {
"name": "8080", "metadata": {
"port": 8080, "creationTimestamp": null,
"targetPort": 8080 "labels": {
"io.kompose.service": "node2"
}
},
"spec": {
"containers": [
{
"name": "node2",
"ports": [
{
"containerPort": 8080
}
],
"resources": {}
}
],
"restartPolicy": "Always"
} }
], },
"selector": { "strategy": {}
"service": "node1"
}
}, },
"status": { "status": {}
"loadBalancer": {} },
} {
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "node3",
"creationTimestamp": null
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "node3"
}
},
"spec": {
"containers": [
{
"name": "node3",
"ports": [
{
"containerPort": 8080
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
},
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "redis",
"creationTimestamp": null
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
},
"spec": {
"containers": [
{
"name": "redis",
"image": "redis",
"ports": [
{
"containerPort": 6379
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
} }
] ]
} }

View File

@ -3,58 +3,6 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": {}, "metadata": {},
"items": [ "items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "node3",
"creationTimestamp": null,
"labels": {
"service": "node3"
}
},
"spec": {
"ports": [
{
"name": "8080",
"port": 8080,
"targetPort": 8080
}
],
"selector": {
"service": "node3"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis"
}
},
"status": {
"loadBalancer": {}
}
},
{ {
"kind": "Service", "kind": "Service",
"apiVersion": "v1", "apiVersion": "v1",
@ -62,7 +10,7 @@
"name": "nginx", "name": "nginx",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "nginx" "io.kompose.service": "nginx"
} }
}, },
"spec": { "spec": {
@ -74,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "nginx" "io.kompose.service": "nginx"
} }
}, },
"status": { "status": {
@ -88,7 +36,7 @@
"name": "node1", "name": "node1",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "node1" "io.kompose.service": "node1"
} }
}, },
"spec": { "spec": {
@ -100,7 +48,7 @@
} }
], ],
"selector": { "selector": {
"service": "node1" "io.kompose.service": "node1"
} }
}, },
"status": { "status": {
@ -114,7 +62,7 @@
"name": "node2", "name": "node2",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "node2" "io.kompose.service": "node2"
} }
}, },
"spec": { "spec": {
@ -126,7 +74,7 @@
} }
], ],
"selector": { "selector": {
"service": "node2" "io.kompose.service": "node2"
} }
}, },
"status": { "status": {
@ -134,208 +82,55 @@
} }
}, },
{ {
"kind": "DeploymentConfig", "kind": "Service",
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "node3", "name": "node3",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "node3" "io.kompose.service": "node3"
} }
}, },
"spec": { "spec": {
"strategy": { "ports": [
"resources": {}
},
"triggers": [
{ {
"type": "ConfigChange" "name": "8080",
}, "port": 8080,
{ "targetPort": 8080
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"node3"
],
"from": {
"kind": "ImageStreamTag",
"name": "node3:latest"
}
}
} }
], ],
"replicas": 1,
"test": false,
"selector": { "selector": {
"service": "node3" "io.kompose.service": "node3"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "node3"
}
},
"spec": {
"containers": [
{
"name": "node3",
"image": " ",
"ports": [
{
"containerPort": 8080
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
} }
}, },
"status": {}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "node3",
"creationTimestamp": null
},
"spec": {},
"status": { "status": {
"dockerImageRepository": "" "loadBalancer": {}
} }
}, },
{ {
"kind": "BuildConfig", "kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "node3",
"creationTimestamp": null
},
"spec": {
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange"
}
],
"runPolicy": "Serial",
"source": {
"type": "Git",
"git": {
"uri": "https://github.com/kubernetes-incubator/kompose.git",
"ref": "master"
},
"contextDir": "script/test/fixtures/ngnix-node-redis/node"
},
"strategy": {
"type": "Docker",
"dockerStrategy": {}
},
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "node3:latest"
}
},
"resources": {},
"postCommit": {}
},
"status": {
"lastVersion": 0
}
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
"strategy": { "ports": [
"resources": {}
},
"triggers": [
{ {
"type": "ConfigChange" "name": "6379",
}, "port": 6379,
{ "targetPort": 6379
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"redis"
],
"from": {
"kind": "ImageStreamTag",
"name": "redis:latest"
}
}
} }
], ],
"replicas": 1,
"test": false,
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"containers": [
{
"name": "redis",
"image": " ",
"ports": [
{
"containerPort": 6379
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
} }
}, },
"status": {}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null
},
"spec": {
"tags": [
{
"name": "latest",
"annotations": null,
"from": {
"kind": "DockerImage",
"name": "redis"
},
"generation": null,
"importPolicy": {}
}
]
},
"status": { "status": {
"dockerImageRepository": "" "loadBalancer": {}
} }
}, },
{ {
@ -379,7 +174,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "nginx" "io.kompose.service": "nginx"
} }
}, },
"spec": { "spec": {
@ -433,8 +228,8 @@
"source": { "source": {
"type": "Git", "type": "Git",
"git": { "git": {
"uri": "https://github.com/kubernetes-incubator/kompose.git", "uri": "git@github.com:procrypt/kompose.git",
"ref": "master" "ref": "empty_vols"
}, },
"contextDir": "script/test/fixtures/ngnix-node-redis/nginx" "contextDir": "script/test/fixtures/ngnix-node-redis/nginx"
}, },
@ -449,7 +244,8 @@
} }
}, },
"resources": {}, "resources": {},
"postCommit": {} "postCommit": {},
"nodeSelector": null
}, },
"status": { "status": {
"lastVersion": 0 "lastVersion": 0
@ -496,7 +292,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "node1" "io.kompose.service": "node1"
} }
}, },
"spec": { "spec": {
@ -550,8 +346,8 @@
"source": { "source": {
"type": "Git", "type": "Git",
"git": { "git": {
"uri": "https://github.com/kubernetes-incubator/kompose.git", "uri": "git@github.com:procrypt/kompose.git",
"ref": "master" "ref": "empty_vols"
}, },
"contextDir": "script/test/fixtures/ngnix-node-redis/node" "contextDir": "script/test/fixtures/ngnix-node-redis/node"
}, },
@ -566,7 +362,8 @@
} }
}, },
"resources": {}, "resources": {},
"postCommit": {} "postCommit": {},
"nodeSelector": null
}, },
"status": { "status": {
"lastVersion": 0 "lastVersion": 0
@ -613,7 +410,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "node2" "io.kompose.service": "node2"
} }
}, },
"spec": { "spec": {
@ -667,8 +464,8 @@
"source": { "source": {
"type": "Git", "type": "Git",
"git": { "git": {
"uri": "https://github.com/kubernetes-incubator/kompose.git", "uri": "git@github.com:procrypt/kompose.git",
"ref": "master" "ref": "empty_vols"
}, },
"contextDir": "script/test/fixtures/ngnix-node-redis/node" "contextDir": "script/test/fixtures/ngnix-node-redis/node"
}, },
@ -683,11 +480,218 @@
} }
}, },
"resources": {}, "resources": {},
"postCommit": {} "postCommit": {},
"nodeSelector": null
}, },
"status": { "status": {
"lastVersion": 0 "lastVersion": 0
} }
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "node3",
"creationTimestamp": null,
"labels": {
"service": "node3"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"node3"
],
"from": {
"kind": "ImageStreamTag",
"name": "node3:latest"
}
}
}
],
"replicas": 1,
"test": false,
"selector": {
"service": "node3"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "node3"
}
},
"spec": {
"containers": [
{
"name": "node3",
"image": " ",
"ports": [
{
"containerPort": 8080
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "node3",
"creationTimestamp": null
},
"spec": {},
"status": {
"dockerImageRepository": ""
}
},
{
"kind": "BuildConfig",
"apiVersion": "v1",
"metadata": {
"name": "node3",
"creationTimestamp": null
},
"spec": {
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange"
}
],
"runPolicy": "Serial",
"source": {
"type": "Git",
"git": {
"uri": "git@github.com:procrypt/kompose.git",
"ref": "empty_vols"
},
"contextDir": "script/test/fixtures/ngnix-node-redis/node"
},
"strategy": {
"type": "Docker",
"dockerStrategy": {}
},
"output": {
"to": {
"kind": "ImageStreamTag",
"name": "node3:latest"
}
},
"resources": {},
"postCommit": {},
"nodeSelector": null
},
"status": {
"lastVersion": 0
}
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"redis"
],
"from": {
"kind": "ImageStreamTag",
"name": "redis:latest"
}
}
}
],
"replicas": 1,
"test": false,
"selector": {
"service": "redis"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
},
"spec": {
"containers": [
{
"name": "redis",
"image": " ",
"ports": [
{
"containerPort": 6379
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null
},
"spec": {
"tags": [
{
"name": "latest",
"annotations": null,
"from": {
"kind": "DockerImage",
"name": "redis"
},
"generation": null,
"importPolicy": {}
}
]
},
"status": {
"dockerImageRepository": ""
}
} }
] ]
} }

View File

@ -10,7 +10,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -28,7 +28,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"status": { "status": {
@ -42,7 +42,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -54,7 +54,7 @@
} }
], ],
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"status": { "status": {
@ -74,7 +74,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -114,7 +114,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {

View File

@ -3,32 +3,6 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": {}, "metadata": {},
"items": [ "items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "web",
"creationTimestamp": null,
"labels": {
"service": "web"
}
},
"spec": {
"ports": [
{
"name": "5000",
"port": 5000,
"targetPort": 5000
}
],
"selector": {
"service": "web"
}
},
"status": {
"loadBalancer": {}
}
},
{ {
"kind": "Service", "kind": "Service",
"apiVersion": "v1", "apiVersion": "v1",
@ -36,7 +10,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -54,7 +28,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"status": { "status": {
@ -62,40 +36,30 @@
} }
}, },
{ {
"kind": "Deployment", "kind": "Service",
"apiVersion": "extensions/v1beta1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "web", "name": "web",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "web"
}
}, },
"spec": { "spec": {
"replicas": 1, "ports": [
"template": { {
"metadata": { "name": "5000",
"creationTimestamp": null, "port": 5000,
"labels": { "targetPort": 5000
"service": "web"
}
},
"spec": {
"containers": [
{
"name": "web",
"image": "tuna/docker-counter23",
"ports": [
{
"containerPort": 5000
}
],
"resources": {}
}
],
"restartPolicy": "Always"
} }
}, ],
"strategy": {} "selector": {
"io.kompose.service": "web"
}
}, },
"status": {} "status": {
"loadBalancer": {}
}
}, },
{ {
"kind": "Deployment", "kind": "Deployment",
@ -110,7 +74,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -136,6 +100,42 @@
"strategy": {} "strategy": {}
}, },
"status": {} "status": {}
},
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "web",
"creationTimestamp": null
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "web"
}
},
"spec": {
"containers": [
{
"name": "web",
"image": "tuna/docker-counter23",
"ports": [
{
"containerPort": 5000
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
},
"strategy": {}
},
"status": {}
} }
] ]
} }

View File

@ -10,7 +10,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -28,7 +28,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"status": { "status": {
@ -42,7 +42,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -54,7 +54,7 @@
} }
], ],
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"status": { "status": {
@ -68,7 +68,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -96,13 +96,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -133,7 +133,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "redis", "name": "redis",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [
@ -160,7 +163,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -188,13 +191,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -221,7 +224,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "web", "name": "web",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "web"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [

View File

@ -10,7 +10,7 @@
"name": "foo", "name": "foo",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "foo" "io.kompose.service": "foo"
} }
}, },
"spec": { "spec": {

View File

@ -10,7 +10,7 @@
"name": "foo", "name": "foo",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "foo" "io.kompose.service": "foo"
} }
}, },
"spec": { "spec": {

View File

@ -10,7 +10,7 @@
"name": "client", "name": "client",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "client" "io.kompose.service": "client"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "client" "io.kompose.service": "client"
} }
}, },
"status": { "status": {
@ -42,7 +42,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "client" "io.kompose.service": "client"
} }
}, },
"spec": { "spec": {

View File

@ -10,7 +10,7 @@
"name": "client", "name": "client",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "client" "io.kompose.service": "client"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "client" "io.kompose.service": "client"
} }
}, },
"status": { "status": {
@ -36,7 +36,7 @@
"name": "client", "name": "client",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "client" "io.kompose.service": "client"
} }
}, },
"spec": { "spec": {
@ -64,13 +64,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "client" "io.kompose.service": "client"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "client" "io.kompose.service": "client"
} }
}, },
"spec": { "spec": {
@ -98,7 +98,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "client", "name": "client",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "client"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [

View File

@ -10,7 +10,7 @@
"name": "client", "name": "client",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "client" "io.kompose.service": "client"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "client" "io.kompose.service": "client"
} }
}, },
"status": { "status": {
@ -42,7 +42,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "client" "io.kompose.service": "client"
} }
}, },
"spec": { "spec": {

View File

@ -10,7 +10,7 @@
"name": "client", "name": "client",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "client" "io.kompose.service": "client"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "client" "io.kompose.service": "client"
} }
}, },
"status": { "status": {
@ -36,7 +36,7 @@
"name": "client", "name": "client",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "client" "io.kompose.service": "client"
} }
}, },
"spec": { "spec": {
@ -64,13 +64,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "client" "io.kompose.service": "client"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "client" "io.kompose.service": "client"
} }
}, },
"spec": { "spec": {
@ -98,7 +98,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "client", "name": "client",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "client"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [

View File

@ -10,7 +10,7 @@
"name": "httpd", "name": "httpd",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "httpd" "io.kompose.service": "httpd"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "httpd" "io.kompose.service": "httpd"
} }
}, },
"status": { "status": {
@ -42,7 +42,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "httpd" "io.kompose.service": "httpd"
} }
}, },
"spec": { "spec": {
@ -76,8 +76,8 @@
} }
}, },
"strategy": { "strategy": {
"type": "Recreate" "type": "Recreate"
} }
}, },
"status": {} "status": {}
}, },
@ -86,7 +86,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "httpd-claim0", "name": "httpd-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "httpd-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [

View File

@ -10,7 +10,7 @@
"name": "httpd", "name": "httpd",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "httpd" "io.kompose.service": "httpd"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "httpd" "io.kompose.service": "httpd"
} }
}, },
"status": { "status": {
@ -36,13 +36,13 @@
"name": "httpd", "name": "httpd",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "httpd" "io.kompose.service": "httpd"
} }
}, },
"spec": { "spec": {
"strategy": { "strategy": {
"resources": {}, "type": "Recreate",
"type": "Recreate" "resources": {}
}, },
"triggers": [ "triggers": [
{ {
@ -65,13 +65,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "httpd" "io.kompose.service": "httpd"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "httpd" "io.kompose.service": "httpd"
} }
}, },
"spec": { "spec": {
@ -112,7 +112,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "httpd", "name": "httpd",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "httpd"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [
@ -137,7 +140,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "httpd-claim0", "name": "httpd-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "httpd-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [

View File

@ -3,32 +3,6 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": {}, "metadata": {},
"items": [ "items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "web",
"creationTimestamp": null,
"labels": {
"service": "web"
}
},
"spec": {
"ports": [
{
"name": "3030",
"port": 3030,
"targetPort": 3000
}
],
"selector": {
"service": "web"
}
},
"status": {
"loadBalancer": {}
}
},
{ {
"kind": "Service", "kind": "Service",
"apiVersion": "v1", "apiVersion": "v1",
@ -36,7 +10,7 @@
"name": "nginx", "name": "nginx",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "nginx" "io.kompose.service": "nginx"
} }
}, },
"spec": { "spec": {
@ -48,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "nginx" "io.kompose.service": "nginx"
} }
}, },
"status": { "status": {
@ -56,80 +30,30 @@
} }
}, },
{ {
"kind": "Deployment", "kind": "Service",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "web",
"creationTimestamp": null
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "web"
}
},
"spec": {
"volumes": [
{
"name": "web-claim0",
"persistentVolumeClaim": {
"claimName": "web-claim0"
}
}
],
"containers": [
{
"name": "web",
"image": "centos/httpd",
"args": [
"nodemon",
"-L",
"app/bin/www"
],
"ports": [
{
"containerPort": 3000
}
],
"resources": {},
"volumeMounts": [
{
"name": "web-claim0",
"mountPath": "/src/app"
}
]
}
],
"restartPolicy": "Always"
}
},
"strategy": {
"type": "Recreate"
}
},
"status": {}
},
{
"kind": "PersistentVolumeClaim",
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "web-claim0", "name": "web",
"creationTimestamp": null "creationTimestamp": null,
}, "labels": {
"spec": { "io.kompose.service": "web"
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "100Mi"
}
} }
}, },
"status": {} "spec": {
"ports": [
{
"name": "3030",
"port": 3030,
"targetPort": 3000
}
],
"selector": {
"io.kompose.service": "web"
}
},
"status": {
"loadBalancer": {}
}
}, },
{ {
"kind": "Deployment", "kind": "Deployment",
@ -144,7 +68,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "nginx" "io.kompose.service": "nginx"
} }
}, },
"spec": { "spec": {
@ -188,8 +112,8 @@
} }
}, },
"strategy": { "strategy": {
"type": "Recreate" "type": "Recreate"
} }
}, },
"status": {} "status": {}
}, },
@ -198,8 +122,90 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "nginx-claim0", "name": "nginx-claim0",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "nginx-claim0"
}
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"resources": {
"requests": {
"storage": "100Mi"
}
}
},
"status": {}
},
{
"kind": "Deployment",
"apiVersion": "extensions/v1beta1",
"metadata": {
"name": "web",
"creationTimestamp": null "creationTimestamp": null
}, },
"spec": {
"replicas": 1,
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "web"
}
},
"spec": {
"volumes": [
{
"name": "web-claim0",
"persistentVolumeClaim": {
"claimName": "web-claim0"
}
}
],
"containers": [
{
"name": "web",
"image": "centos/httpd",
"args": [
"nodemon",
"-L",
"app/bin/www"
],
"ports": [
{
"containerPort": 3000
}
],
"resources": {},
"volumeMounts": [
{
"name": "web-claim0",
"mountPath": "/src/app"
}
]
}
],
"restartPolicy": "Always"
}
},
"strategy": {
"type": "Recreate"
}
},
"status": {}
},
{
"kind": "PersistentVolumeClaim",
"apiVersion": "v1",
"metadata": {
"name": "web-claim0",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "web-claim0"
}
},
"spec": { "spec": {
"accessModes": [ "accessModes": [
"ReadWriteOnce" "ReadWriteOnce"

View File

@ -10,7 +10,7 @@
"name": "nginx", "name": "nginx",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "nginx" "io.kompose.service": "nginx"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "nginx" "io.kompose.service": "nginx"
} }
}, },
"status": { "status": {
@ -36,7 +36,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -48,7 +48,7 @@
} }
], ],
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"status": { "status": {
@ -62,13 +62,13 @@
"name": "nginx", "name": "nginx",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "nginx" "io.kompose.service": "nginx"
} }
}, },
"spec": { "spec": {
"strategy": { "strategy": {
"resources": {}, "type": "Recreate",
"type": "Recreate" "resources": {}
}, },
"triggers": [ "triggers": [
{ {
@ -91,13 +91,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "nginx" "io.kompose.service": "nginx"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "nginx" "io.kompose.service": "nginx"
} }
}, },
"spec": { "spec": {
@ -148,7 +148,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "nginx", "name": "nginx",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "nginx"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [
@ -173,7 +176,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "nginx-claim0", "name": "nginx-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "nginx-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [
@ -194,13 +200,13 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
"strategy": { "strategy": {
"resources": {}, "type": "Recreate",
"type": "Recreate" "resources": {}
}, },
"triggers": [ "triggers": [
{ {
@ -223,13 +229,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -275,7 +281,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "web", "name": "web",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "web"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [
@ -300,7 +309,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "web-claim0", "name": "web-claim0",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "web-claim0"
}
}, },
"spec": { "spec": {
"accessModes": [ "accessModes": [

View File

@ -10,7 +10,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"status": { "status": {
@ -36,7 +36,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -48,7 +48,7 @@
} }
], ],
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"status": { "status": {
@ -68,7 +68,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -104,7 +104,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {

View File

@ -10,7 +10,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"status": { "status": {
@ -36,7 +36,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -48,7 +48,7 @@
} }
], ],
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"status": { "status": {
@ -62,7 +62,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -90,13 +90,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -123,7 +123,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "redis", "name": "redis",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [
@ -150,7 +153,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -178,13 +181,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -211,7 +214,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "web", "name": "web",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "web"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [

View File

@ -10,7 +10,7 @@
"name": "redis", "name": "redis",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -22,7 +22,7 @@
} }
], ],
"selector": { "selector": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"status": { "status": {
@ -36,7 +36,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -48,7 +48,7 @@
} }
], ],
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"status": { "status": {
@ -68,7 +68,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "redis" "io.kompose.service": "redis"
} }
}, },
"spec": { "spec": {
@ -104,7 +104,7 @@
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {

View File

@ -3,32 +3,6 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": {}, "metadata": {},
"items": [ "items": [
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"service": "redis"
}
},
"status": {
"loadBalancer": {}
}
},
{ {
"kind": "Service", "kind": "Service",
"apiVersion": "v1", "apiVersion": "v1",
@ -36,7 +10,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -48,101 +22,39 @@
} }
], ],
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
}
},
"status": {
"loadBalancer": {}
}
},
{
"kind": "Service",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
},
"spec": {
"ports": [
{
"name": "6379",
"port": 6379,
"targetPort": 6379
}
],
"selector": {
"io.kompose.service": "redis"
} }
}, },
"status": { "status": {
"loadBalancer": {} "loadBalancer": {}
} }
}, },
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"redis"
],
"from": {
"kind": "ImageStreamTag",
"name": "redis:3.0"
}
}
}
],
"replicas": 1,
"test": false,
"selector": {
"service": "redis"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"service": "redis"
}
},
"spec": {
"containers": [
{
"name": "redis",
"image": " ",
"ports": [
{
"containerPort": 6379
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null
},
"spec": {
"tags": [
{
"name": "3.0",
"annotations": null,
"from": {
"kind": "DockerImage",
"name": "redis:3.0"
},
"generation": null,
"importPolicy": {}
}
]
},
"status": {
"dockerImageRepository": ""
}
},
{ {
"kind": "DeploymentConfig", "kind": "DeploymentConfig",
"apiVersion": "v1", "apiVersion": "v1",
@ -150,7 +62,7 @@
"name": "web", "name": "web",
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -178,13 +90,13 @@
"replicas": 1, "replicas": 1,
"test": false, "test": false,
"selector": { "selector": {
"service": "web" "io.kompose.service": "web"
}, },
"template": { "template": {
"metadata": { "metadata": {
"creationTimestamp": null, "creationTimestamp": null,
"labels": { "labels": {
"service": "web" "io.kompose.service": "web"
} }
}, },
"spec": { "spec": {
@ -211,7 +123,10 @@
"apiVersion": "v1", "apiVersion": "v1",
"metadata": { "metadata": {
"name": "web", "name": "web",
"creationTimestamp": null "creationTimestamp": null,
"labels": {
"io.kompose.service": "web"
}
}, },
"spec": { "spec": {
"tags": [ "tags": [
@ -230,6 +145,97 @@
"status": { "status": {
"dockerImageRepository": "" "dockerImageRepository": ""
} }
},
{
"kind": "DeploymentConfig",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
},
"spec": {
"strategy": {
"resources": {}
},
"triggers": [
{
"type": "ConfigChange"
},
{
"type": "ImageChange",
"imageChangeParams": {
"automatic": true,
"containerNames": [
"redis"
],
"from": {
"kind": "ImageStreamTag",
"name": "redis:3.0"
}
}
}
],
"replicas": 1,
"test": false,
"selector": {
"io.kompose.service": "redis"
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
},
"spec": {
"containers": [
{
"name": "redis",
"image": " ",
"ports": [
{
"containerPort": 6379
}
],
"resources": {}
}
],
"restartPolicy": "Always"
}
}
},
"status": {}
},
{
"kind": "ImageStream",
"apiVersion": "v1",
"metadata": {
"name": "redis",
"creationTimestamp": null,
"labels": {
"io.kompose.service": "redis"
}
},
"spec": {
"tags": [
{
"name": "3.0",
"annotations": null,
"from": {
"kind": "DockerImage",
"name": "redis:3.0"
},
"generation": null,
"importPolicy": {}
}
]
},
"status": {
"dockerImageRepository": ""
}
} }
] ]
} }

View File

@ -1,26 +0,0 @@
/*
Package logrus is a structured logger for Go, completely API compatible with the standard library logger.
The simplest way to use Logrus is simply the package-level exported logger:
package main
import (
log "github.com/Sirupsen/logrus"
)
func main() {
log.WithFields(log.Fields{
"animal": "walrus",
"number": 1,
"size": 10,
}).Info("A walrus appears")
}
Output:
time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10
For a full guide visit https://github.com/Sirupsen/logrus
*/
package logrus

View File

@ -8,9 +8,6 @@ import (
"time" "time"
) )
// Defines the key when adding errors using WithError.
var ErrorKey = "error"
// An entry is the final or intermediate Logrus logging entry. It contains all // An entry is the final or intermediate Logrus logging entry. It contains all
// the fields passed with WithField{,s}. It's finally logged when Debug, Info, // the fields passed with WithField{,s}. It's finally logged when Debug, Info,
// Warn, Error, Fatal or Panic is called on it. These objects can be reused and // Warn, Error, Fatal or Panic is called on it. These objects can be reused and
@ -56,11 +53,6 @@ func (entry *Entry) String() (string, error) {
return reader.String(), err return reader.String(), err
} }
// Add an error as single field (using the key defined in ErrorKey) to the Entry.
func (entry *Entry) WithError(err error) *Entry {
return entry.WithField(ErrorKey, err)
}
// Add a single field to the Entry. // Add a single field to the Entry.
func (entry *Entry) WithField(key string, value interface{}) *Entry { func (entry *Entry) WithField(key string, value interface{}) *Entry {
return entry.WithFields(Fields{key: value}) return entry.WithFields(Fields{key: value})
@ -68,7 +60,7 @@ func (entry *Entry) WithField(key string, value interface{}) *Entry {
// Add a map of fields to the Entry. // Add a map of fields to the Entry.
func (entry *Entry) WithFields(fields Fields) *Entry { func (entry *Entry) WithFields(fields Fields) *Entry {
data := make(Fields, len(entry.Data)+len(fields)) data := Fields{}
for k, v := range entry.Data { for k, v := range entry.Data {
data[k] = v data[k] = v
} }
@ -78,14 +70,12 @@ func (entry *Entry) WithFields(fields Fields) *Entry {
return &Entry{Logger: entry.Logger, Data: data} return &Entry{Logger: entry.Logger, Data: data}
} }
// This function is not declared with a pointer value because otherwise func (entry *Entry) log(level Level, msg string) {
// race conditions will occur when using multiple goroutines
func (entry Entry) log(level Level, msg string) {
entry.Time = time.Now() entry.Time = time.Now()
entry.Level = level entry.Level = level
entry.Message = msg entry.Message = msg
if err := entry.Logger.Hooks.Fire(level, &entry); err != nil { if err := entry.Logger.Hooks.Fire(level, entry); err != nil {
entry.Logger.mu.Lock() entry.Logger.mu.Lock()
fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err) fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err)
entry.Logger.mu.Unlock() entry.Logger.mu.Unlock()
@ -110,7 +100,7 @@ func (entry Entry) log(level Level, msg string) {
// panic() to use in Entry#Panic(), we avoid the allocation by checking // panic() to use in Entry#Panic(), we avoid the allocation by checking
// directly here. // directly here.
if level <= PanicLevel { if level <= PanicLevel {
panic(&entry) panic(entry)
} }
} }
@ -198,7 +188,6 @@ func (entry *Entry) Fatalf(format string, args ...interface{}) {
if entry.Logger.Level >= FatalLevel { if entry.Logger.Level >= FatalLevel {
entry.Fatal(fmt.Sprintf(format, args...)) entry.Fatal(fmt.Sprintf(format, args...))
} }
os.Exit(1)
} }
func (entry *Entry) Panicf(format string, args ...interface{}) { func (entry *Entry) Panicf(format string, args ...interface{}) {
@ -245,7 +234,6 @@ func (entry *Entry) Fatalln(args ...interface{}) {
if entry.Logger.Level >= FatalLevel { if entry.Logger.Level >= FatalLevel {
entry.Fatal(entry.sprintlnn(args...)) entry.Fatal(entry.sprintlnn(args...))
} }
os.Exit(1)
} }
func (entry *Entry) Panicln(args ...interface{}) { func (entry *Entry) Panicln(args ...interface{}) {

View File

@ -48,11 +48,6 @@ func AddHook(hook Hook) {
std.Hooks.Add(hook) std.Hooks.Add(hook)
} }
// WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key.
func WithError(err error) *Entry {
return std.WithField(ErrorKey, err)
}
// WithField creates an entry from the standard logger and adds a field to // WithField creates an entry from the standard logger and adds a field to
// it. If you want multiple fields, use `WithFields`. // it. If you want multiple fields, use `WithFields`.
// //

View File

@ -11,11 +11,11 @@ type Hook interface {
} }
// Internal type for storing the hooks on a logger instance. // Internal type for storing the hooks on a logger instance.
type LevelHooks map[Level][]Hook type levelHooks map[Level][]Hook
// Add a hook to an instance of logger. This is called with // Add a hook to an instance of logger. This is called with
// `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface. // `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface.
func (hooks LevelHooks) Add(hook Hook) { func (hooks levelHooks) Add(hook Hook) {
for _, level := range hook.Levels() { for _, level := range hook.Levels() {
hooks[level] = append(hooks[level], hook) hooks[level] = append(hooks[level], hook)
} }
@ -23,7 +23,7 @@ func (hooks LevelHooks) Add(hook Hook) {
// Fire all the hooks for the passed level. Used by `entry.log` to fire // Fire all the hooks for the passed level. Used by `entry.log` to fire
// appropriate hooks for a log entry. // appropriate hooks for a log entry.
func (hooks LevelHooks) Fire(level Level, entry *Entry) error { func (hooks levelHooks) Fire(level Level, entry *Entry) error {
for _, hook := range hooks[level] { for _, hook := range hooks[level] {
if err := hook.Fire(entry); err != nil { if err := hook.Fire(entry); err != nil {
return err return err

View File

@ -24,12 +24,11 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) {
} }
prefixFieldClashes(data) prefixFieldClashes(data)
timestampFormat := f.TimestampFormat if f.TimestampFormat == "" {
if timestampFormat == "" { f.TimestampFormat = DefaultTimestampFormat
timestampFormat = DefaultTimestampFormat
} }
data["time"] = entry.Time.Format(timestampFormat) data["time"] = entry.Time.Format(f.TimestampFormat)
data["msg"] = entry.Message data["msg"] = entry.Message
data["level"] = entry.Level.String() data["level"] = entry.Level.String()

View File

@ -8,13 +8,13 @@ import (
type Logger struct { type Logger struct {
// The logs are `io.Copy`'d to this in a mutex. It's common to set this to a // The logs are `io.Copy`'d to this in a mutex. It's common to set this to a
// file, or leave it default which is `os.Stderr`. You can also set this to // file, or leave it default which is `os.Stdout`. You can also set this to
// something more adventorous, such as logging to Kafka. // something more adventorous, such as logging to Kafka.
Out io.Writer Out io.Writer
// Hooks for the logger instance. These allow firing events based on logging // Hooks for the logger instance. These allow firing events based on logging
// levels and log entries. For example, to send errors to an error tracking // levels and log entries. For example, to send errors to an error tracking
// service, log to StatsD or dump the core on fatal errors. // service, log to StatsD or dump the core on fatal errors.
Hooks LevelHooks Hooks levelHooks
// All log entries pass through the formatter before logged to Out. The // All log entries pass through the formatter before logged to Out. The
// included formatters are `TextFormatter` and `JSONFormatter` for which // included formatters are `TextFormatter` and `JSONFormatter` for which
// TextFormatter is the default. In development (when a TTY is attached) it // TextFormatter is the default. In development (when a TTY is attached) it
@ -37,7 +37,7 @@ type Logger struct {
// var log = &Logger{ // var log = &Logger{
// Out: os.Stderr, // Out: os.Stderr,
// Formatter: new(JSONFormatter), // Formatter: new(JSONFormatter),
// Hooks: make(LevelHooks), // Hooks: make(levelHooks),
// Level: logrus.DebugLevel, // Level: logrus.DebugLevel,
// } // }
// //
@ -46,14 +46,14 @@ func New() *Logger {
return &Logger{ return &Logger{
Out: os.Stderr, Out: os.Stderr,
Formatter: new(TextFormatter), Formatter: new(TextFormatter),
Hooks: make(LevelHooks), Hooks: make(levelHooks),
Level: InfoLevel, Level: InfoLevel,
} }
} }
// Adds a field to the log entry, note that you it doesn't log until you call // Adds a field to the log entry, note that you it doesn't log until you call
// Debug, Print, Info, Warn, Fatal or Panic. It only creates a log entry. // Debug, Print, Info, Warn, Fatal or Panic. It only creates a log entry.
// If you want multiple fields, use `WithFields`. // Ff you want multiple fields, use `WithFields`.
func (logger *Logger) WithField(key string, value interface{}) *Entry { func (logger *Logger) WithField(key string, value interface{}) *Entry {
return NewEntry(logger).WithField(key, value) return NewEntry(logger).WithField(key, value)
} }
@ -64,12 +64,6 @@ func (logger *Logger) WithFields(fields Fields) *Entry {
return NewEntry(logger).WithFields(fields) return NewEntry(logger).WithFields(fields)
} }
// Add an error as single field to the log entry. All it does is call
// `WithError` for the given `error`.
func (logger *Logger) WithError(err error) *Entry {
return NewEntry(logger).WithError(err)
}
func (logger *Logger) Debugf(format string, args ...interface{}) { func (logger *Logger) Debugf(format string, args ...interface{}) {
if logger.Level >= DebugLevel { if logger.Level >= DebugLevel {
NewEntry(logger).Debugf(format, args...) NewEntry(logger).Debugf(format, args...)
@ -108,7 +102,6 @@ func (logger *Logger) Fatalf(format string, args ...interface{}) {
if logger.Level >= FatalLevel { if logger.Level >= FatalLevel {
NewEntry(logger).Fatalf(format, args...) NewEntry(logger).Fatalf(format, args...)
} }
os.Exit(1)
} }
func (logger *Logger) Panicf(format string, args ...interface{}) { func (logger *Logger) Panicf(format string, args ...interface{}) {
@ -155,7 +148,6 @@ func (logger *Logger) Fatal(args ...interface{}) {
if logger.Level >= FatalLevel { if logger.Level >= FatalLevel {
NewEntry(logger).Fatal(args...) NewEntry(logger).Fatal(args...)
} }
os.Exit(1)
} }
func (logger *Logger) Panic(args ...interface{}) { func (logger *Logger) Panic(args ...interface{}) {
@ -202,7 +194,6 @@ func (logger *Logger) Fatalln(args ...interface{}) {
if logger.Level >= FatalLevel { if logger.Level >= FatalLevel {
NewEntry(logger).Fatalln(args...) NewEntry(logger).Fatalln(args...)
} }
os.Exit(1)
} }
func (logger *Logger) Panicln(args ...interface{}) { func (logger *Logger) Panicln(args ...interface{}) {

View File

@ -3,7 +3,6 @@ package logrus
import ( import (
"fmt" "fmt"
"log" "log"
"strings"
) )
// Fields type, used to pass to `WithFields`. // Fields type, used to pass to `WithFields`.
@ -34,7 +33,7 @@ func (level Level) String() string {
// ParseLevel takes a string level and returns the Logrus log level constant. // ParseLevel takes a string level and returns the Logrus log level constant.
func ParseLevel(lvl string) (Level, error) { func ParseLevel(lvl string) (Level, error) {
switch strings.ToLower(lvl) { switch lvl {
case "panic": case "panic":
return PanicLevel, nil return PanicLevel, nil
case "fatal": case "fatal":
@ -53,16 +52,6 @@ func ParseLevel(lvl string) (Level, error) {
return l, fmt.Errorf("not a valid logrus Level: %q", lvl) return l, fmt.Errorf("not a valid logrus Level: %q", lvl)
} }
// A constant exposing all logging levels
var AllLevels = []Level{
PanicLevel,
FatalLevel,
ErrorLevel,
WarnLevel,
InfoLevel,
DebugLevel,
}
// These are the different logging levels. You can set the logging level to log // These are the different logging levels. You can set the logging level to log
// on your instance of logger, obtained with `logrus.New()`. // on your instance of logger, obtained with `logrus.New()`.
const ( const (
@ -85,11 +74,7 @@ const (
) )
// Won't compile if StdLogger can't be realized by a log.Logger // Won't compile if StdLogger can't be realized by a log.Logger
var ( var _ StdLogger = &log.Logger{}
_ StdLogger = &log.Logger{}
_ StdLogger = &Entry{}
_ StdLogger = &Logger{}
)
// StdLogger is what your logrus-enabled library should take, that way // StdLogger is what your logrus-enabled library should take, that way
// it'll accept a stdlib logger and a logrus logger. There's no standard // it'll accept a stdlib logger and a logrus logger. There's no standard
@ -107,37 +92,3 @@ type StdLogger interface {
Panicf(string, ...interface{}) Panicf(string, ...interface{})
Panicln(...interface{}) Panicln(...interface{})
} }
// The FieldLogger interface generalizes the Entry and Logger types
type FieldLogger interface {
WithField(key string, value interface{}) *Entry
WithFields(fields Fields) *Entry
WithError(err error) *Entry
Debugf(format string, args ...interface{})
Infof(format string, args ...interface{})
Printf(format string, args ...interface{})
Warnf(format string, args ...interface{})
Warningf(format string, args ...interface{})
Errorf(format string, args ...interface{})
Fatalf(format string, args ...interface{})
Panicf(format string, args ...interface{})
Debug(args ...interface{})
Info(args ...interface{})
Print(args ...interface{})
Warn(args ...interface{})
Warning(args ...interface{})
Error(args ...interface{})
Fatal(args ...interface{})
Panic(args ...interface{})
Debugln(args ...interface{})
Infoln(args ...interface{})
Println(args ...interface{})
Warnln(args ...interface{})
Warningln(args ...interface{})
Errorln(args ...interface{})
Fatalln(args ...interface{})
Panicln(args ...interface{})
}

12
vendor/github.com/Sirupsen/logrus/terminal_darwin.go generated vendored Normal file
View File

@ -0,0 +1,12 @@
// Based on ssh/terminal:
// Copyright 2013 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package logrus
import "syscall"
const ioctlReadTermios = syscall.TIOCGETA
type Termios syscall.Termios

20
vendor/github.com/Sirupsen/logrus/terminal_freebsd.go generated vendored Normal file
View File

@ -0,0 +1,20 @@
/*
Go 1.2 doesn't include Termios for FreeBSD. This should be added in 1.3 and this could be merged with terminal_darwin.
*/
package logrus
import (
"syscall"
)
const ioctlReadTermios = syscall.TIOCGETA
type Termios struct {
Iflag uint32
Oflag uint32
Cflag uint32
Lflag uint32
Cc [20]uint8
Ispeed uint32
Ospeed uint32
}

View File

@ -3,7 +3,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// +build linux darwin freebsd openbsd netbsd dragonfly // +build linux darwin freebsd openbsd
package logrus package logrus
@ -12,9 +12,9 @@ import (
"unsafe" "unsafe"
) )
// IsTerminal returns true if stderr's file descriptor is a terminal. // IsTerminal returns true if the given file descriptor is a terminal.
func IsTerminal() bool { func IsTerminal() bool {
fd := syscall.Stderr fd := syscall.Stdout
var termios Termios var termios Termios
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
return err == 0 return err == 0

View File

@ -1,5 +1,3 @@
// +build darwin freebsd openbsd netbsd dragonfly
package logrus package logrus
import "syscall" import "syscall"

View File

@ -1,15 +0,0 @@
// +build solaris
package logrus
import (
"os"
"golang.org/x/sys/unix"
)
// IsTerminal returns true if the given file descriptor is a terminal.
func IsTerminal() bool {
_, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA)
return err == nil
}

View File

@ -18,9 +18,9 @@ var (
procGetConsoleMode = kernel32.NewProc("GetConsoleMode") procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
) )
// IsTerminal returns true if stderr's file descriptor is a terminal. // IsTerminal returns true if the given file descriptor is a terminal.
func IsTerminal() bool { func IsTerminal() bool {
fd := syscall.Stderr fd := syscall.Stdout
var st uint32 var st uint32
r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0)
return r != 0 && e == 0 return r != 0 && e == 0

View File

@ -3,7 +3,6 @@ package logrus
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"runtime"
"sort" "sort"
"strings" "strings"
"time" "time"
@ -70,23 +69,19 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
prefixFieldClashes(entry.Data) prefixFieldClashes(entry.Data)
isColorTerminal := isTerminal && (runtime.GOOS != "windows") isColored := (f.ForceColors || isTerminal) && !f.DisableColors
isColored := (f.ForceColors || isColorTerminal) && !f.DisableColors
timestampFormat := f.TimestampFormat if f.TimestampFormat == "" {
if timestampFormat == "" { f.TimestampFormat = DefaultTimestampFormat
timestampFormat = DefaultTimestampFormat
} }
if isColored { if isColored {
f.printColored(b, entry, keys, timestampFormat) f.printColored(b, entry, keys)
} else { } else {
if !f.DisableTimestamp { if !f.DisableTimestamp {
f.appendKeyValue(b, "time", entry.Time.Format(timestampFormat)) f.appendKeyValue(b, "time", entry.Time.Format(f.TimestampFormat))
} }
f.appendKeyValue(b, "level", entry.Level.String()) f.appendKeyValue(b, "level", entry.Level.String())
if entry.Message != "" { f.appendKeyValue(b, "msg", entry.Message)
f.appendKeyValue(b, "msg", entry.Message)
}
for _, key := range keys { for _, key := range keys {
f.appendKeyValue(b, key, entry.Data[key]) f.appendKeyValue(b, key, entry.Data[key])
} }
@ -96,7 +91,7 @@ func (f *TextFormatter) Format(entry *Entry) ([]byte, error) {
return b.Bytes(), nil return b.Bytes(), nil
} }
func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []string, timestampFormat string) { func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []string) {
var levelColor int var levelColor int
switch entry.Level { switch entry.Level {
case DebugLevel: case DebugLevel:
@ -114,11 +109,11 @@ func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []strin
if !f.FullTimestamp { if !f.FullTimestamp {
fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d] %-44s ", levelColor, levelText, miniTS(), entry.Message) fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%04d] %-44s ", levelColor, levelText, miniTS(), entry.Message)
} else { } else {
fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %-44s ", levelColor, levelText, entry.Time.Format(timestampFormat), entry.Message) fmt.Fprintf(b, "\x1b[%dm%s\x1b[0m[%s] %-44s ", levelColor, levelText, entry.Time.Format(f.TimestampFormat), entry.Message)
} }
for _, k := range keys { for _, k := range keys {
v := entry.Data[k] v := entry.Data[k]
fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=%+v", levelColor, k, v) fmt.Fprintf(b, " \x1b[%dm%s\x1b[0m=%v", levelColor, k, v)
} }
} }
@ -134,28 +129,21 @@ func needsQuoting(text string) bool {
return true return true
} }
func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) { func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key, value interface{}) {
switch value.(type) {
b.WriteString(key)
b.WriteByte('=')
switch value := value.(type) {
case string: case string:
if needsQuoting(value) { if needsQuoting(value.(string)) {
b.WriteString(value) fmt.Fprintf(b, "%v=%s ", key, value)
} else { } else {
fmt.Fprintf(b, "%q", value) fmt.Fprintf(b, "%v=%q ", key, value)
} }
case error: case error:
errmsg := value.Error() if needsQuoting(value.(error).Error()) {
if needsQuoting(errmsg) { fmt.Fprintf(b, "%v=%s ", key, value)
b.WriteString(errmsg)
} else { } else {
fmt.Fprintf(b, "%q", value) fmt.Fprintf(b, "%v=%q ", key, value)
} }
default: default:
fmt.Fprint(b, value) fmt.Fprintf(b, "%v=%v ", key, value)
} }
b.WriteByte(' ')
} }

View File

@ -431,7 +431,7 @@ func strctVal(s interface{}) reflect.Value {
v := reflect.ValueOf(s) v := reflect.ValueOf(s)
// if pointer get the underlying element≤ // if pointer get the underlying element≤
if v.Kind() == reflect.Ptr { for v.Kind() == reflect.Ptr {
v = v.Elem() v = v.Elem()
} }
@ -558,7 +558,10 @@ func (s *Struct) nested(val reflect.Value) interface{} {
// TODO(arslan): should this be optional? // TODO(arslan): should this be optional?
// do not iterate of non struct types, just pass the value. Ie: []int, // do not iterate of non struct types, just pass the value. Ie: []int,
// []string, co... We only iterate further if it's a struct. // []string, co... We only iterate further if it's a struct.
if val.Type().Elem().Kind() != reflect.Struct { // i.e []foo or []*foo
if val.Type().Elem().Kind() != reflect.Struct &&
!(val.Type().Elem().Kind() == reflect.Ptr &&
val.Type().Elem().Elem().Kind() == reflect.Struct) {
finalVal = val.Interface() finalVal = val.Interface()
break break
} }

View File

@ -9,7 +9,6 @@ package fsnotify
import ( import (
"bytes" "bytes"
"errors"
"fmt" "fmt"
) )
@ -61,6 +60,3 @@ func (op Op) String() string {
func (e Event) String() string { func (e Event) String() string {
return fmt.Sprintf("%q: %s", e.Name, e.Op.String()) return fmt.Sprintf("%q: %s", e.Name, e.Op.String())
} }
// Common errors that can be reported by a watcher
var ErrEventOverflow = errors.New("fsnotify queue overflow")

View File

@ -245,15 +245,6 @@ func (w *Watcher) readEvents() {
mask := uint32(raw.Mask) mask := uint32(raw.Mask)
nameLen := uint32(raw.Len) nameLen := uint32(raw.Len)
if mask&unix.IN_Q_OVERFLOW != 0 {
select {
case w.Errors <- ErrEventOverflow:
case <-w.done:
return
}
}
// If the event happened to the watched directory or the watched file, the kernel // If the event happened to the watched directory or the watched file, the kernel
// doesn't append the filename to the event, but we would like to always fill the // doesn't append the filename to the event, but we would like to always fill the
// the "Name" field with a valid filename. We retrieve the path of the watch from // the "Name" field with a valid filename. We retrieve the path of the watch from

View File

@ -91,7 +91,7 @@ func (d *decoder) decode(name string, node ast.Node, result reflect.Value) error
return d.decodeBool(name, node, result) return d.decodeBool(name, node, result)
case reflect.Float64: case reflect.Float64:
return d.decodeFloat(name, node, result) return d.decodeFloat(name, node, result)
case reflect.Int, reflect.Int32, reflect.Int64: case reflect.Int:
return d.decodeInt(name, node, result) return d.decodeInt(name, node, result)
case reflect.Interface: case reflect.Interface:
// When we see an interface, we make our own thing // When we see an interface, we make our own thing
@ -164,11 +164,7 @@ func (d *decoder) decodeInt(name string, node ast.Node, result reflect.Value) er
return err return err
} }
if result.Kind() == reflect.Interface { result.Set(reflect.ValueOf(int(v)))
result.Set(reflect.ValueOf(int(v)))
} else {
result.SetInt(v)
}
return nil return nil
case token.STRING: case token.STRING:
v, err := strconv.ParseInt(n.Token.Value().(string), 0, 0) v, err := strconv.ParseInt(n.Token.Value().(string), 0, 0)
@ -176,11 +172,7 @@ func (d *decoder) decodeInt(name string, node ast.Node, result reflect.Value) er
return err return err
} }
if result.Kind() == reflect.Interface { result.Set(reflect.ValueOf(int(v)))
result.Set(reflect.ValueOf(int(v)))
} else {
result.SetInt(v)
}
return nil return nil
} }
} }

View File

@ -256,10 +256,7 @@ func (p *Parser) objectKey() ([]*ast.ObjectKey, error) {
keyCount++ keyCount++
keys = append(keys, &ast.ObjectKey{Token: p.tok}) keys = append(keys, &ast.ObjectKey{Token: p.tok})
case token.ILLEGAL: case token.ILLEGAL:
return keys, &PosError{ fmt.Println("illegal")
Pos: p.tok.Pos,
Err: fmt.Errorf("illegal character"),
}
default: default:
return keys, &PosError{ return keys, &PosError{
Pos: p.tok.Pos, Pos: p.tok.Pos,
@ -346,7 +343,7 @@ func (p *Parser) listType() (*ast.ListType, error) {
} }
} }
switch tok.Type { switch tok.Type {
case token.BOOL, token.NUMBER, token.FLOAT, token.STRING, token.HEREDOC: case token.NUMBER, token.FLOAT, token.STRING, token.HEREDOC:
node, err := p.literalType() node, err := p.literalType()
if err != nil { if err != nil {
return nil, err return nil, err
@ -388,16 +385,12 @@ func (p *Parser) listType() (*ast.ListType, error) {
} }
l.Add(node) l.Add(node)
needComma = true needComma = true
case token.BOOL:
// TODO(arslan) should we support? not supported by HCL yet
case token.LBRACK: case token.LBRACK:
node, err := p.listType() // TODO(arslan) should we support nested lists? Even though it's
if err != nil { // written in README of HCL, it's not a part of the grammar
return nil, &PosError{ // (not defined in parse.y)
Pos: tok.Pos,
Err: fmt.Errorf(
"error while trying to parse list within list: %s", err),
}
}
l.Add(node)
case token.RBRACK: case token.RBRACK:
// finished // finished
l.Rbrack = p.tok.Pos l.Rbrack = p.tok.Pos

View File

@ -480,7 +480,7 @@ func (s *Scanner) scanString() {
// read character after quote // read character after quote
ch := s.next() ch := s.next()
if (ch == '\n' && braces == 0) || ch < 0 || ch == eof { if ch < 0 || ch == eof {
s.err("literal not terminated") s.err("literal not terminated")
return return
} }

View File

@ -27,9 +27,6 @@ func Unquote(s string) (t string, err error) {
if quote != '"' { if quote != '"' {
return "", ErrSyntax return "", ErrSyntax
} }
if !contains(s, '$') && !contains(s, '{') && contains(s, '\n') {
return "", ErrSyntax
}
// Is it trivial? Avoid allocation. // Is it trivial? Avoid allocation.
if !contains(s, '\\') && !contains(s, quote) && !contains(s, '$') { if !contains(s, '\\') && !contains(s, quote) && !contains(s, '$') {
@ -87,10 +84,6 @@ func Unquote(s string) (t string, err error) {
} }
} }
if s[0] == '\n' {
return "", ErrSyntax
}
c, multibyte, ss, err := unquoteChar(s, quote) c, multibyte, ss, err := unquoteChar(s, quote)
if err != nil { if err != nil {
return "", err return "", err

View File

@ -1,4 +1,4 @@
// Copyright 2017 Frank Schroeder. All rights reserved. // Copyright 2016 Frank Schroeder. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
@ -158,16 +158,16 @@ func dec(p *Properties, key string, def *string, opts map[string]string, v refle
// keydef returns the property key and the default value based on the // keydef returns the property key and the default value based on the
// name of the struct field and the options in the tag. // name of the struct field and the options in the tag.
keydef := func(f reflect.StructField) (string, *string, map[string]string) { keydef := func(f reflect.StructField) (string, *string, map[string]string) {
_key, _opts := parseTag(f.Tag.Get("properties")) key, opts := parseTag(f.Tag.Get("properties"))
var _def *string var def *string
if d, ok := _opts["default"]; ok { if d, ok := opts["default"]; ok {
_def = &d def = &d
} }
if _key != "" { if key != "" {
return _key, _def, _opts return key, def, opts
} }
return f.Name, _def, _opts return f.Name, def, opts
} }
switch { switch {
@ -190,7 +190,7 @@ func dec(p *Properties, key string, def *string, opts map[string]string, v refle
fv := v.Field(i) fv := v.Field(i)
fk, def, opts := keydef(t.Field(i)) fk, def, opts := keydef(t.Field(i))
if !fv.CanSet() { if !fv.CanSet() {
return fmt.Errorf("cannot set %s", t.Field(i).Name) return fmt.Errorf("cannot set ", t.Field(i).Name)
} }
if fk == "-" { if fk == "-" {
continue continue
@ -223,7 +223,7 @@ func dec(p *Properties, key string, def *string, opts map[string]string, v refle
case isMap(t): case isMap(t):
valT := t.Elem() valT := t.Elem()
m := reflect.MakeMap(t) m := reflect.MakeMap(t)
for postfix := range p.FilterStripPrefix(key + ".").m { for postfix, _ := range p.FilterStripPrefix(key + ".").m {
pp := strings.SplitN(postfix, ".", 2) pp := strings.SplitN(postfix, ".", 2)
mk, mv := pp[0], reflect.New(valT) mk, mv := pp[0], reflect.New(valT)
if err := dec(p, key+"."+mk, nil, nil, mv); err != nil { if err := dec(p, key+"."+mk, nil, nil, mv); err != nil {
@ -274,6 +274,7 @@ func isArray(t reflect.Type) bool { return t.Kind() == reflect.Array || t.Kin
func isBool(t reflect.Type) bool { return t.Kind() == reflect.Bool } func isBool(t reflect.Type) bool { return t.Kind() == reflect.Bool }
func isDuration(t reflect.Type) bool { return t == reflect.TypeOf(time.Second) } func isDuration(t reflect.Type) bool { return t == reflect.TypeOf(time.Second) }
func isMap(t reflect.Type) bool { return t.Kind() == reflect.Map } func isMap(t reflect.Type) bool { return t.Kind() == reflect.Map }
func isNumeric(t reflect.Type) bool { return isInt(t) || isUint(t) || isFloat(t) }
func isPtr(t reflect.Type) bool { return t.Kind() == reflect.Ptr } func isPtr(t reflect.Type) bool { return t.Kind() == reflect.Ptr }
func isString(t reflect.Type) bool { return t.Kind() == reflect.String } func isString(t reflect.Type) bool { return t.Kind() == reflect.String }
func isStruct(t reflect.Type) bool { return t.Kind() == reflect.Struct } func isStruct(t reflect.Type) bool { return t.Kind() == reflect.Struct }

View File

@ -1,4 +1,4 @@
// Copyright 2017 Frank Schroeder. All rights reserved. // Copyright 2016 Frank Schroeder. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.

View File

@ -1,4 +1,4 @@
// Copyright 2017 Frank Schroeder. All rights reserved. // Copyright 2016 Frank Schroeder. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.

View File

@ -1,4 +1,4 @@
// Copyright 2017 Frank Schroeder. All rights reserved. // Copyright 2016 Frank Schroeder. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// //
@ -72,7 +72,7 @@ type lexer struct {
// next returns the next rune in the input. // next returns the next rune in the input.
func (l *lexer) next() rune { func (l *lexer) next() rune {
if l.pos >= len(l.input) { if int(l.pos) >= len(l.input) {
l.width = 0 l.width = 0
return eof return eof
} }
@ -96,8 +96,8 @@ func (l *lexer) backup() {
// emit passes an item back to the client. // emit passes an item back to the client.
func (l *lexer) emit(t itemType) { func (l *lexer) emit(t itemType) {
i := item{t, l.start, string(l.runes)} item := item{t, l.start, string(l.runes)}
l.items <- i l.items <- item
l.start = l.pos l.start = l.pos
l.runes = l.runes[:0] l.runes = l.runes[:0]
} }
@ -114,7 +114,7 @@ func (l *lexer) appendRune(r rune) {
// accept consumes the next rune if it's from the valid set. // accept consumes the next rune if it's from the valid set.
func (l *lexer) accept(valid string) bool { func (l *lexer) accept(valid string) bool {
if strings.ContainsRune(valid, l.next()) { if strings.IndexRune(valid, l.next()) >= 0 {
return true return true
} }
l.backup() l.backup()
@ -123,7 +123,7 @@ func (l *lexer) accept(valid string) bool {
// acceptRun consumes a run of runes from the valid set. // acceptRun consumes a run of runes from the valid set.
func (l *lexer) acceptRun(valid string) { func (l *lexer) acceptRun(valid string) {
for strings.ContainsRune(valid, l.next()) { for strings.IndexRune(valid, l.next()) >= 0 {
} }
l.backup() l.backup()
} }
@ -156,9 +156,9 @@ func (l *lexer) errorf(format string, args ...interface{}) stateFn {
// nextItem returns the next item from the input. // nextItem returns the next item from the input.
func (l *lexer) nextItem() item { func (l *lexer) nextItem() item {
i := <-l.items item := <-l.items
l.lastPos = i.pos l.lastPos = item.pos
return i return item
} }
// lex creates a new scanner for the input string. // lex creates a new scanner for the input string.
@ -279,7 +279,8 @@ func lexValue(l *lexer) stateFn {
for { for {
switch r := l.next(); { switch r := l.next(); {
case isEscape(r): case isEscape(r):
if isEOL(l.peek()) { r := l.peek()
if isEOL(r) {
l.next() l.next()
l.acceptRun(whitespace) l.acceptRun(whitespace)
} else { } else {

View File

@ -1,10 +1,11 @@
// Copyright 2017 Frank Schroeder. All rights reserved. // Copyright 2016 Frank Schroeder. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package properties package properties
import ( import (
"bytes"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@ -35,14 +36,14 @@ func LoadString(s string) (*Properties, error) {
// LoadFile reads a file into a Properties struct. // LoadFile reads a file into a Properties struct.
func LoadFile(filename string, enc Encoding) (*Properties, error) { func LoadFile(filename string, enc Encoding) (*Properties, error) {
return loadAll([]string{filename}, enc, false) return loadFiles([]string{filename}, enc, false)
} }
// LoadFiles reads multiple files in the given order into // LoadFiles reads multiple files in the given order into
// a Properties struct. If 'ignoreMissing' is true then // a Properties struct. If 'ignoreMissing' is true then
// non-existent files will not be reported as error. // non-existent files will not be reported as error.
func LoadFiles(filenames []string, enc Encoding, ignoreMissing bool) (*Properties, error) { func LoadFiles(filenames []string, enc Encoding, ignoreMissing bool) (*Properties, error) {
return loadAll(filenames, enc, ignoreMissing) return loadFiles(filenames, enc, ignoreMissing)
} }
// LoadURL reads the content of the URL into a Properties struct. // LoadURL reads the content of the URL into a Properties struct.
@ -54,7 +55,7 @@ func LoadFiles(filenames []string, enc Encoding, ignoreMissing bool) (*Propertie
// encoding is set to UTF-8. A missing content type header is // encoding is set to UTF-8. A missing content type header is
// interpreted as 'text/plain; charset=utf-8'. // interpreted as 'text/plain; charset=utf-8'.
func LoadURL(url string) (*Properties, error) { func LoadURL(url string) (*Properties, error) {
return loadAll([]string{url}, UTF8, false) return loadURLs([]string{url}, false)
} }
// LoadURLs reads the content of multiple URLs in the given order into a // LoadURLs reads the content of multiple URLs in the given order into a
@ -62,15 +63,7 @@ func LoadURL(url string) (*Properties, error) {
// not be reported as error. See LoadURL for the Content-Type header // not be reported as error. See LoadURL for the Content-Type header
// and the encoding. // and the encoding.
func LoadURLs(urls []string, ignoreMissing bool) (*Properties, error) { func LoadURLs(urls []string, ignoreMissing bool) (*Properties, error) {
return loadAll(urls, UTF8, ignoreMissing) return loadURLs(urls, ignoreMissing)
}
// LoadAll reads the content of multiple URLs or files in the given order into a
// Properties struct. If 'ignoreMissing' is true then a 404 status code or missing file will
// not be reported as error. Encoding sets the encoding for files. For the URLs please see
// LoadURL for the Content-Type header and the encoding.
func LoadAll(names []string, enc Encoding, ignoreMissing bool) (*Properties, error) {
return loadAll(names, enc, ignoreMissing)
} }
// MustLoadString reads an UTF8 string into a Properties struct and // MustLoadString reads an UTF8 string into a Properties struct and
@ -98,21 +91,13 @@ func MustLoadURL(url string) *Properties {
return must(LoadURL(url)) return must(LoadURL(url))
} }
// MustLoadURLs reads the content of multiple URLs in the given order into a // MustLoadFiles reads the content of multiple URLs in the given order into a
// Properties struct and panics on error. If 'ignoreMissing' is true then a 404 // Properties struct and panics on error. If 'ignoreMissing' is true then a 404
// status code will not be reported as error. // status code will not be reported as error.
func MustLoadURLs(urls []string, ignoreMissing bool) *Properties { func MustLoadURLs(urls []string, ignoreMissing bool) *Properties {
return must(LoadURLs(urls, ignoreMissing)) return must(LoadURLs(urls, ignoreMissing))
} }
// MustLoadAll reads the content of multiple URLs or files in the given order into a
// Properties struct. If 'ignoreMissing' is true then a 404 status code or missing file will
// not be reported as error. Encoding sets the encoding for files. For the URLs please see
// LoadURL for the Content-Type header and the encoding. It panics on error.
func MustLoadAll(names []string, enc Encoding, ignoreMissing bool) *Properties {
return must(LoadAll(names, enc, ignoreMissing))
}
func loadBuf(buf []byte, enc Encoding) (*Properties, error) { func loadBuf(buf []byte, enc Encoding) (*Properties, error) {
p, err := parse(convert(buf, enc)) p, err := parse(convert(buf, enc))
if err != nil { if err != nil {
@ -121,80 +106,66 @@ func loadBuf(buf []byte, enc Encoding) (*Properties, error) {
return p, p.check() return p, p.check()
} }
func loadAll(names []string, enc Encoding, ignoreMissing bool) (*Properties, error) { func loadFiles(filenames []string, enc Encoding, ignoreMissing bool) (*Properties, error) {
result := NewProperties() var buf bytes.Buffer
for _, name := range names { for _, filename := range filenames {
n, err := expandName(name) f, err := expandFilename(filename)
if err != nil { if err != nil {
return nil, err return nil, err
} }
var p *Properties
if strings.HasPrefix(n, "http://") || strings.HasPrefix(n, "https://") { data, err := ioutil.ReadFile(f)
p, err = loadURL(n, ignoreMissing)
} else {
p, err = loadFile(n, enc, ignoreMissing)
}
if err != nil { if err != nil {
if ignoreMissing && os.IsNotExist(err) {
LogPrintf("properties: %s not found. skipping", filename)
continue
}
return nil, err return nil, err
} }
result.Merge(p)
// concatenate the buffers and add a new line in case
// the previous file didn't end with a new line
buf.Write(data)
buf.WriteRune('\n')
} }
return result, result.check() return loadBuf(buf.Bytes(), enc)
} }
func loadFile(filename string, enc Encoding, ignoreMissing bool) (*Properties, error) { func loadURLs(urls []string, ignoreMissing bool) (*Properties, error) {
data, err := ioutil.ReadFile(filename) var buf bytes.Buffer
if err != nil { for _, u := range urls {
if ignoreMissing && os.IsNotExist(err) { resp, err := http.Get(u)
LogPrintf("properties: %s not found. skipping", filename) if err != nil {
return NewProperties(), nil return nil, fmt.Errorf("properties: error fetching %q. %s", u, err)
}
if resp.StatusCode == 404 && ignoreMissing {
LogPrintf("properties: %s returned %d. skipping", u, resp.StatusCode)
continue
}
if resp.StatusCode != 200 {
return nil, fmt.Errorf("properties: %s returned %d", u, resp.StatusCode)
}
body, err := ioutil.ReadAll(resp.Body)
resp.Body.Close()
if err != nil {
return nil, fmt.Errorf("properties: %s error reading response. %s", u, err)
} }
return nil, err
}
p, err := parse(convert(data, enc))
if err != nil {
return nil, err
}
return p, nil
}
func loadURL(url string, ignoreMissing bool) (*Properties, error) { ct := resp.Header.Get("Content-Type")
resp, err := http.Get(url) var enc Encoding
if err != nil { switch strings.ToLower(ct) {
return nil, fmt.Errorf("properties: error fetching %q. %s", url, err) case "text/plain", "text/plain; charset=iso-8859-1", "text/plain; charset=latin1":
} enc = ISO_8859_1
if resp.StatusCode == 404 && ignoreMissing { case "", "text/plain; charset=utf-8":
LogPrintf("properties: %s returned %d. skipping", url, resp.StatusCode) enc = UTF8
return NewProperties(), nil default:
} return nil, fmt.Errorf("properties: invalid content type %s", ct)
if resp.StatusCode != 200 { }
return nil, fmt.Errorf("properties: %s returned %d", url, resp.StatusCode)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("properties: %s error reading response. %s", url, err)
}
if err = resp.Body.Close(); err != nil {
return nil, fmt.Errorf("properties: %s error reading response. %s", url, err)
}
ct := resp.Header.Get("Content-Type") buf.WriteString(convert(body, enc))
var enc Encoding buf.WriteRune('\n')
switch strings.ToLower(ct) {
case "text/plain", "text/plain; charset=iso-8859-1", "text/plain; charset=latin1":
enc = ISO_8859_1
case "", "text/plain; charset=utf-8":
enc = UTF8
default:
return nil, fmt.Errorf("properties: invalid content type %s", ct)
} }
return loadBuf(buf.Bytes(), UTF8)
p, err := parse(convert(body, enc))
if err != nil {
return nil, err
}
return p, nil
} }
func must(p *Properties, err error) *Properties { func must(p *Properties, err error) *Properties {
@ -204,12 +175,12 @@ func must(p *Properties, err error) *Properties {
return p return p
} }
// expandName expands ${ENV_VAR} expressions in a name. // expandFilename expands ${ENV_VAR} expressions in a filename.
// If the environment variable does not exist then it will be replaced // If the environment variable does not exist then it will be replaced
// with an empty string. Malformed expressions like "${ENV_VAR" will // with an empty string. Malformed expressions like "${ENV_VAR" will
// be reported as error. // be reported as error.
func expandName(name string) (string, error) { func expandFilename(filename string) (string, error) {
return expand(name, make(map[string]bool), "${", "}", make(map[string]string)) return expand(filename, make(map[string]bool), "${", "}", make(map[string]string))
} }
// Interprets a byte buffer either as an ISO-8859-1 or UTF-8 encoded string. // Interprets a byte buffer either as an ISO-8859-1 or UTF-8 encoded string.

View File

@ -1,4 +1,4 @@
// Copyright 2017 Frank Schroeder. All rights reserved. // Copyright 2016 Frank Schroeder. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.

View File

@ -1,4 +1,4 @@
// Copyright 2017 Frank Schroeder. All rights reserved. // Copyright 2016 Frank Schroeder. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
@ -28,10 +28,8 @@ type ErrorHandlerFunc func(error)
// functions. The default is LogFatalHandler. // functions. The default is LogFatalHandler.
var ErrorHandler ErrorHandlerFunc = LogFatalHandler var ErrorHandler ErrorHandlerFunc = LogFatalHandler
// LogHandlerFunc defines the function prototype for logging errors.
type LogHandlerFunc func(fmt string, args ...interface{}) type LogHandlerFunc func(fmt string, args ...interface{})
// LogPrintf defines a log handler which uses log.Printf.
var LogPrintf LogHandlerFunc = log.Printf var LogPrintf LogHandlerFunc = log.Printf
// LogFatalHandler handles the error by logging a fatal error and exiting. // LogFatalHandler handles the error by logging a fatal error and exiting.
@ -446,8 +444,6 @@ func (p *Properties) FilterRegexp(re *regexp.Regexp) *Properties {
pp := NewProperties() pp := NewProperties()
for _, k := range p.k { for _, k := range p.k {
if re.MatchString(k) { if re.MatchString(k) {
// TODO(fs): we are ignoring the error which flags a circular reference.
// TODO(fs): since we are just copying a subset of keys this cannot happen (fingers crossed)
pp.Set(k, p.m[k]) pp.Set(k, p.m[k])
} }
} }
@ -460,8 +456,6 @@ func (p *Properties) FilterPrefix(prefix string) *Properties {
pp := NewProperties() pp := NewProperties()
for _, k := range p.k { for _, k := range p.k {
if strings.HasPrefix(k, prefix) { if strings.HasPrefix(k, prefix) {
// TODO(fs): we are ignoring the error which flags a circular reference.
// TODO(fs): since we are just copying a subset of keys this cannot happen (fingers crossed)
pp.Set(k, p.m[k]) pp.Set(k, p.m[k])
} }
} }
@ -475,9 +469,6 @@ func (p *Properties) FilterStripPrefix(prefix string) *Properties {
n := len(prefix) n := len(prefix)
for _, k := range p.k { for _, k := range p.k {
if len(k) > len(prefix) && strings.HasPrefix(k, prefix) { if len(k) > len(prefix) && strings.HasPrefix(k, prefix) {
// TODO(fs): we are ignoring the error which flags a circular reference.
// TODO(fs): since we are modifying keys I am not entirely sure whether we can create a circular reference
// TODO(fs): this function should probably return an error but the signature is fixed
pp.Set(k[n:], p.m[k]) pp.Set(k[n:], p.m[k])
} }
} }
@ -492,7 +483,9 @@ func (p *Properties) Len() int {
// Keys returns all keys in the same order as in the input. // Keys returns all keys in the same order as in the input.
func (p *Properties) Keys() []string { func (p *Properties) Keys() []string {
keys := make([]string, len(p.k)) keys := make([]string, len(p.k))
copy(keys, p.k) for i, k := range p.k {
keys[i] = k
}
return keys return keys
} }
@ -631,32 +624,12 @@ func (p *Properties) Delete(key string) {
newKeys := []string{} newKeys := []string{}
for _, k := range p.k { for _, k := range p.k {
if k != key { if k != key {
newKeys = append(newKeys, k) newKeys = append(newKeys, key)
} }
} }
p.k = newKeys p.k = newKeys
} }
// Merge merges properties, comments and keys from other *Properties into p
func (p *Properties) Merge(other *Properties) {
for k, v := range other.m {
p.m[k] = v
}
for k, v := range other.c {
p.c[k] = v
}
outer:
for _, otherKey := range other.k {
for _, key := range p.k {
if otherKey == key {
continue outer
}
}
p.k = append(p.k, otherKey)
}
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// check expands all values and returns an error if a circular reference or // check expands all values and returns an error if a circular reference or

View File

@ -1,4 +1,4 @@
// Copyright 2017 Frank Schroeder. All rights reserved. // Copyright 2016 Frank Schroeder. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.

View File

@ -1,5 +1,5 @@
// The mapstructure package exposes functionality to convert an // The mapstructure package exposes functionality to convert an
// arbitrary map[string]interface{} into a native Go structure. // abitrary map[string]interface{} into a native Go structure.
// //
// The Go structure can be arbitrarily complex, containing slices, // The Go structure can be arbitrarily complex, containing slices,
// other structs, etc. and the decoder will properly decode nested // other structs, etc. and the decoder will properly decode nested
@ -69,9 +69,6 @@ type DecoderConfig struct {
// - empty array = empty map and vice versa // - empty array = empty map and vice versa
// - negative numbers to overflowed uint values (base 10) // - negative numbers to overflowed uint values (base 10)
// - slice of maps to a merged map // - slice of maps to a merged map
// - single values are converted to slices if required. Each
// element is weakly decoded. For example: "4" can become []int{4}
// if the target type is an int slice.
// //
WeaklyTypedInput bool WeaklyTypedInput bool
@ -205,7 +202,7 @@ func (d *Decoder) decode(name string, data interface{}, val reflect.Value) error
d.config.DecodeHook, d.config.DecodeHook,
dataVal.Type(), val.Type(), data) dataVal.Type(), val.Type(), data)
if err != nil { if err != nil {
return fmt.Errorf("error decoding '%s': %s", name, err) return err
} }
} }
@ -232,8 +229,6 @@ func (d *Decoder) decode(name string, data interface{}, val reflect.Value) error
err = d.decodePtr(name, data, val) err = d.decodePtr(name, data, val)
case reflect.Slice: case reflect.Slice:
err = d.decodeSlice(name, data, val) err = d.decodeSlice(name, data, val)
case reflect.Func:
err = d.decodeFunc(name, data, val)
default: default:
// If we reached this point then we weren't able to decode it // If we reached this point then we weren't able to decode it
return fmt.Errorf("%s: unsupported type: %s", name, dataKind) return fmt.Errorf("%s: unsupported type: %s", name, dataKind)
@ -551,12 +546,7 @@ func (d *Decoder) decodePtr(name string, data interface{}, val reflect.Value) er
// into that. Then set the value of the pointer to this type. // into that. Then set the value of the pointer to this type.
valType := val.Type() valType := val.Type()
valElemType := valType.Elem() valElemType := valType.Elem()
realVal := reflect.New(valElemType)
realVal := val
if realVal.IsNil() || d.config.ZeroFields {
realVal = reflect.New(valElemType)
}
if err := d.decode(name, data, reflect.Indirect(realVal)); err != nil { if err := d.decode(name, data, reflect.Indirect(realVal)); err != nil {
return err return err
} }
@ -565,19 +555,6 @@ func (d *Decoder) decodePtr(name string, data interface{}, val reflect.Value) er
return nil return nil
} }
func (d *Decoder) decodeFunc(name string, data interface{}, val reflect.Value) error {
// Create an element of the concrete (non pointer) type and decode
// into that. Then set the value of the pointer to this type.
dataVal := reflect.Indirect(reflect.ValueOf(data))
if val.Type() != dataVal.Type() {
return fmt.Errorf(
"'%s' expected type '%s', got unconvertible type '%s'",
name, val.Type(), dataVal.Type())
}
val.Set(dataVal)
return nil
}
func (d *Decoder) decodeSlice(name string, data interface{}, val reflect.Value) error { func (d *Decoder) decodeSlice(name string, data interface{}, val reflect.Value) error {
dataVal := reflect.Indirect(reflect.ValueOf(data)) dataVal := reflect.Indirect(reflect.ValueOf(data))
dataValKind := dataVal.Kind() dataValKind := dataVal.Kind()
@ -585,44 +562,26 @@ func (d *Decoder) decodeSlice(name string, data interface{}, val reflect.Value)
valElemType := valType.Elem() valElemType := valType.Elem()
sliceType := reflect.SliceOf(valElemType) sliceType := reflect.SliceOf(valElemType)
valSlice := val // Check input type
if valSlice.IsNil() || d.config.ZeroFields { if dataValKind != reflect.Array && dataValKind != reflect.Slice {
// Check input type // Accept empty map instead of array/slice in weakly typed mode
if dataValKind != reflect.Array && dataValKind != reflect.Slice { if d.config.WeaklyTypedInput && dataVal.Kind() == reflect.Map && dataVal.Len() == 0 {
if d.config.WeaklyTypedInput { val.Set(reflect.MakeSlice(sliceType, 0, 0))
switch { return nil
// Empty maps turn into empty slices } else {
case dataValKind == reflect.Map:
if dataVal.Len() == 0 {
val.Set(reflect.MakeSlice(sliceType, 0, 0))
return nil
}
// All other types we try to convert to the slice type
// and "lift" it into it. i.e. a string becomes a string slice.
default:
// Just re-try this function with data as a slice.
return d.decodeSlice(name, []interface{}{data}, val)
}
}
return fmt.Errorf( return fmt.Errorf(
"'%s': source data must be an array or slice, got %s", name, dataValKind) "'%s': source data must be an array or slice, got %s", name, dataValKind)
} }
// Make a new slice to hold our result, same size as the original data.
valSlice = reflect.MakeSlice(sliceType, dataVal.Len(), dataVal.Len())
} }
// Make a new slice to hold our result, same size as the original data.
valSlice := reflect.MakeSlice(sliceType, dataVal.Len(), dataVal.Len())
// Accumulate any errors // Accumulate any errors
errors := make([]string, 0) errors := make([]string, 0)
for i := 0; i < dataVal.Len(); i++ { for i := 0; i < dataVal.Len(); i++ {
currentData := dataVal.Index(i).Interface() currentData := dataVal.Index(i).Interface()
for valSlice.Len() <= i {
valSlice = reflect.Append(valSlice, reflect.Zero(valElemType))
}
currentField := valSlice.Index(i) currentField := valSlice.Index(i)
fieldName := fmt.Sprintf("%s[%d]", name, i) fieldName := fmt.Sprintf("%s[%d]", name, i)

View File

@ -31,13 +31,8 @@ func NewReader(rd io.Reader) *Reader {
} }
} }
type runeWithSize struct {
r rune
size int
}
func (rd *Reader) feedBuffer() error { func (rd *Reader) feedBuffer() error {
r, size, err := rd.input.ReadRune() r, _, err := rd.input.ReadRune()
if err != nil { if err != nil {
if err != io.EOF { if err != io.EOF {
@ -46,9 +41,7 @@ func (rd *Reader) feedBuffer() error {
r = EOF r = EOF
} }
newRuneWithSize := runeWithSize{r, size} rd.buffer.PushBack(r)
rd.buffer.PushBack(newRuneWithSize)
if rd.current == nil { if rd.current == nil {
rd.current = rd.buffer.Back() rd.current = rd.buffer.Back()
} }
@ -56,17 +49,17 @@ func (rd *Reader) feedBuffer() error {
} }
// ReadRune reads the next rune from buffer, or from the underlying reader if needed. // ReadRune reads the next rune from buffer, or from the underlying reader if needed.
func (rd *Reader) ReadRune() (rune, int, error) { func (rd *Reader) ReadRune() (rune, error) {
if rd.current == rd.buffer.Back() || rd.current == nil { if rd.current == rd.buffer.Back() || rd.current == nil {
err := rd.feedBuffer() err := rd.feedBuffer()
if err != nil { if err != nil {
return EOF, 0, err return EOF, err
} }
} }
runeWithSize := rd.current.Value.(runeWithSize) r := rd.current.Value
rd.current = rd.current.Next() rd.current = rd.current.Next()
return runeWithSize.r, runeWithSize.size, nil return r.(rune), nil
} }
// UnreadRune pushes back the previously read rune in the buffer, extending it if needed. // UnreadRune pushes back the previously read rune in the buffer, extending it if needed.
@ -91,9 +84,9 @@ func (rd *Reader) Forget() {
} }
} }
// PeekRune returns at most the next n runes, reading from the uderlying source if // Peek returns at most the next n runes, reading from the uderlying source if
// needed. Does not move the current index. It includes EOF if reached. // needed. Does not move the current index. It includes EOF if reached.
func (rd *Reader) PeekRunes(n int) []rune { func (rd *Reader) Peek(n int) []rune {
res := make([]rune, 0, n) res := make([]rune, 0, n)
cursor := rd.current cursor := rd.current
for i := 0; i < n; i++ { for i := 0; i < n; i++ {
@ -105,7 +98,7 @@ func (rd *Reader) PeekRunes(n int) []rune {
cursor = rd.buffer.Back() cursor = rd.buffer.Back()
} }
if cursor != nil { if cursor != nil {
r := cursor.Value.(runeWithSize).r r := cursor.Value.(rune)
res = append(res, r) res = append(res, r)
if r == EOF { if r == EOF {
return res return res

View File

@ -1,21 +0,0 @@
The MIT License (MIT)
Copyright (c) 2013 - 2017 Thomas Pelletier, Eric Anderton
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -22,8 +22,8 @@
// After parsing TOML data with Load() or LoadFile(), use the Has() and Get() // After parsing TOML data with Load() or LoadFile(), use the Has() and Get()
// methods on the returned TomlTree, to find your way through the document data. // methods on the returned TomlTree, to find your way through the document data.
// //
// if tree.Has("foo") { // if tree.Has('foo') {
// fmt.Println("foo is:", tree.Get("foo")) // fmt.Prinln("foo is: %v", tree.Get('foo'))
// } // }
// //
// Working with Paths // Working with Paths
@ -44,10 +44,10 @@
// it avoids having to parse the passed key for '.' delimiters. // it avoids having to parse the passed key for '.' delimiters.
// //
// // looks for a key named 'baz', within struct 'bar', within struct 'foo' // // looks for a key named 'baz', within struct 'bar', within struct 'foo'
// tree.HasPath([]string{"foo","bar","baz"}) // tree.HasPath(string{}{"foo","bar","baz"})
// //
// // returns the key at this path, if it is there // // returns the key at this path, if it is there
// tree.GetPath([]string{"foo","bar","baz"}) // tree.GetPath(string{}{"foo","bar","baz"})
// //
// Note that this is distinct from the heavyweight query syntax supported by // Note that this is distinct from the heavyweight query syntax supported by
// TomlTree.Query() and the Query() struct (see below). // TomlTree.Query() and the Query() struct (see below).

View File

@ -4,7 +4,6 @@ package toml
import ( import (
"bytes" "bytes"
"errors"
"fmt" "fmt"
"unicode" "unicode"
) )
@ -13,7 +12,6 @@ func parseKey(key string) ([]string, error) {
groups := []string{} groups := []string{}
var buffer bytes.Buffer var buffer bytes.Buffer
inQuotes := false inQuotes := false
wasInQuotes := false
escapeNext := false escapeNext := false
ignoreSpace := true ignoreSpace := true
expectDot := false expectDot := false
@ -35,27 +33,16 @@ func parseKey(key string) ([]string, error) {
escapeNext = true escapeNext = true
continue continue
case '"': case '"':
if inQuotes {
groups = append(groups, buffer.String())
buffer.Reset()
wasInQuotes = true
}
inQuotes = !inQuotes inQuotes = !inQuotes
expectDot = false expectDot = false
case '.': case '.':
if inQuotes { if inQuotes {
buffer.WriteRune(char) buffer.WriteRune(char)
} else { } else {
if !wasInQuotes { groups = append(groups, buffer.String())
if buffer.Len() == 0 { buffer.Reset()
return nil, errors.New("empty table key")
}
groups = append(groups, buffer.String())
buffer.Reset()
}
ignoreSpace = true ignoreSpace = true
expectDot = false expectDot = false
wasInQuotes = false
} }
case ' ': case ' ':
if inQuotes { if inQuotes {
@ -68,23 +55,23 @@ func parseKey(key string) ([]string, error) {
return nil, fmt.Errorf("invalid bare character: %c", char) return nil, fmt.Errorf("invalid bare character: %c", char)
} }
if !inQuotes && expectDot { if !inQuotes && expectDot {
return nil, errors.New("what?") return nil, fmt.Errorf("what?")
} }
buffer.WriteRune(char) buffer.WriteRune(char)
expectDot = false expectDot = false
} }
} }
if inQuotes { if inQuotes {
return nil, errors.New("mismatched quotes") return nil, fmt.Errorf("mismatched quotes")
} }
if escapeNext { if escapeNext {
return nil, errors.New("unfinished escape sequence") return nil, fmt.Errorf("unfinished escape sequence")
} }
if buffer.Len() > 0 { if buffer.Len() > 0 {
groups = append(groups, buffer.String()) groups = append(groups, buffer.String())
} }
if len(groups) == 0 { if len(groups) == 0 {
return nil, errors.New("empty key") return nil, fmt.Errorf("empty key")
} }
return groups, nil return groups, nil
} }

View File

@ -1,6 +1,6 @@
// TOML lexer. // TOML lexer.
// //
// Written using the principles developed by Rob Pike in // Written using the principles developped by Rob Pike in
// http://www.youtube.com/watch?v=HxaD_trXwRE // http://www.youtube.com/watch?v=HxaD_trXwRE
package toml package toml
@ -36,7 +36,7 @@ type tomlLexer struct {
// Basic read operations on input // Basic read operations on input
func (l *tomlLexer) read() rune { func (l *tomlLexer) read() rune {
r, _, err := l.input.ReadRune() r, err := l.input.ReadRune()
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -89,7 +89,7 @@ func (l *tomlLexer) emit(t tokenType) {
} }
func (l *tomlLexer) peek() rune { func (l *tomlLexer) peek() rune {
r, _, err := l.input.ReadRune() r, err := l.input.ReadRune()
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -99,7 +99,7 @@ func (l *tomlLexer) peek() rune {
func (l *tomlLexer) follow(next string) bool { func (l *tomlLexer) follow(next string) bool {
for _, expectedRune := range next { for _, expectedRune := range next {
r, _, err := l.input.ReadRune() r, err := l.input.ReadRune()
defer l.input.UnreadRune() defer l.input.UnreadRune()
if err != nil { if err != nil {
panic(err) panic(err)
@ -129,9 +129,9 @@ func (l *tomlLexer) lexVoid() tomlLexStateFn {
next := l.peek() next := l.peek()
switch next { switch next {
case '[': case '[':
return l.lexTableKey return l.lexKeyGroup
case '#': case '#':
return l.lexComment(l.lexVoid) return l.lexComment
case '=': case '=':
return l.lexEqual return l.lexEqual
case '\r': case '\r':
@ -182,7 +182,7 @@ func (l *tomlLexer) lexRvalue() tomlLexStateFn {
case '}': case '}':
return l.lexRightCurlyBrace return l.lexRightCurlyBrace
case '#': case '#':
return l.lexComment(l.lexRvalue) return l.lexComment
case '"': case '"':
return l.lexString return l.lexString
case '\'': case '\'':
@ -219,7 +219,7 @@ func (l *tomlLexer) lexRvalue() tomlLexStateFn {
break break
} }
possibleDate := string(l.input.PeekRunes(35)) possibleDate := string(l.input.Peek(35))
dateMatch := dateRegexp.FindString(possibleDate) dateMatch := dateRegexp.FindString(possibleDate)
if dateMatch != "" { if dateMatch != "" {
l.fastForward(len(dateMatch)) l.fastForward(len(dateMatch))
@ -309,17 +309,15 @@ func (l *tomlLexer) lexKey() tomlLexStateFn {
return l.lexVoid return l.lexVoid
} }
func (l *tomlLexer) lexComment(previousState tomlLexStateFn) tomlLexStateFn { func (l *tomlLexer) lexComment() tomlLexStateFn {
return func() tomlLexStateFn { for next := l.peek(); next != '\n' && next != eof; next = l.peek() {
for next := l.peek(); next != '\n' && next != eof; next = l.peek() { if next == '\r' && l.follow("\r\n") {
if next == '\r' && l.follow("\r\n") { break
break
}
l.next()
} }
l.ignore() l.next()
return previousState
} }
l.ignore()
return l.lexVoid
} }
func (l *tomlLexer) lexLeftBracket() tomlLexStateFn { func (l *tomlLexer) lexLeftBracket() tomlLexStateFn {
@ -518,21 +516,21 @@ func (l *tomlLexer) lexString() tomlLexStateFn {
return l.lexRvalue return l.lexRvalue
} }
func (l *tomlLexer) lexTableKey() tomlLexStateFn { func (l *tomlLexer) lexKeyGroup() tomlLexStateFn {
l.next() l.next()
if l.peek() == '[' { if l.peek() == '[' {
// token '[[' signifies an array of tables // token '[[' signifies an array of anonymous key groups
l.next() l.next()
l.emit(tokenDoubleLeftBracket) l.emit(tokenDoubleLeftBracket)
return l.lexInsideTableArrayKey return l.lexInsideKeyGroupArray
} }
// vanilla table key // vanilla key group
l.emit(tokenLeftBracket) l.emit(tokenLeftBracket)
return l.lexInsideTableKey return l.lexInsideKeyGroup
} }
func (l *tomlLexer) lexInsideTableArrayKey() tomlLexStateFn { func (l *tomlLexer) lexInsideKeyGroupArray() tomlLexStateFn {
for r := l.peek(); r != eof; r = l.peek() { for r := l.peek(); r != eof; r = l.peek() {
switch r { switch r {
case ']': case ']':
@ -547,15 +545,15 @@ func (l *tomlLexer) lexInsideTableArrayKey() tomlLexStateFn {
l.emit(tokenDoubleRightBracket) l.emit(tokenDoubleRightBracket)
return l.lexVoid return l.lexVoid
case '[': case '[':
return l.errorf("table array key cannot contain ']'") return l.errorf("group name cannot contain ']'")
default: default:
l.next() l.next()
} }
} }
return l.errorf("unclosed table array key") return l.errorf("unclosed key group array")
} }
func (l *tomlLexer) lexInsideTableKey() tomlLexStateFn { func (l *tomlLexer) lexInsideKeyGroup() tomlLexStateFn {
for r := l.peek(); r != eof; r = l.peek() { for r := l.peek(); r != eof; r = l.peek() {
switch r { switch r {
case ']': case ']':
@ -566,12 +564,12 @@ func (l *tomlLexer) lexInsideTableKey() tomlLexStateFn {
l.emit(tokenRightBracket) l.emit(tokenRightBracket)
return l.lexVoid return l.lexVoid
case '[': case '[':
return l.errorf("table key cannot contain ']'") return l.errorf("group name cannot contain ']'")
default: default:
l.next() l.next()
} }
} }
return l.errorf("unclosed table key") return l.errorf("unclosed key group")
} }
func (l *tomlLexer) lexRightBracket() tomlLexStateFn { func (l *tomlLexer) lexRightBracket() tomlLexStateFn {

View File

@ -3,7 +3,6 @@
package toml package toml
import ( import (
"errors"
"fmt" "fmt"
"reflect" "reflect"
"regexp" "regexp"
@ -16,8 +15,8 @@ type tomlParser struct {
flow chan token flow chan token
tree *TomlTree tree *TomlTree
tokensBuffer []token tokensBuffer []token
currentTable []string currentGroup []string
seenTableKeys []string seenGroupKeys []string
} }
type tomlParserStateFn func() tomlParserStateFn type tomlParserStateFn func() tomlParserStateFn
@ -96,13 +95,13 @@ func (p *tomlParser) parseGroupArray() tomlParserStateFn {
startToken := p.getToken() // discard the [[ startToken := p.getToken() // discard the [[
key := p.getToken() key := p.getToken()
if key.typ != tokenKeyGroupArray { if key.typ != tokenKeyGroupArray {
p.raiseError(key, "unexpected token %s, was expecting a table array key", key) p.raiseError(key, "unexpected token %s, was expecting a key group array", key)
} }
// get or create table array element at the indicated part in the path // get or create group array element at the indicated part in the path
keys, err := parseKey(key.val) keys, err := parseKey(key.val)
if err != nil { if err != nil {
p.raiseError(key, "invalid table array key: %s", err) p.raiseError(key, "invalid group array key: %s", err)
} }
p.tree.createSubTree(keys[:len(keys)-1], startToken.Position) // create parent entries p.tree.createSubTree(keys[:len(keys)-1], startToken.Position) // create parent entries
destTree := p.tree.GetPath(keys) destTree := p.tree.GetPath(keys)
@ -112,32 +111,32 @@ func (p *tomlParser) parseGroupArray() tomlParserStateFn {
} else if target, ok := destTree.([]*TomlTree); ok && target != nil { } else if target, ok := destTree.([]*TomlTree); ok && target != nil {
array = destTree.([]*TomlTree) array = destTree.([]*TomlTree)
} else { } else {
p.raiseError(key, "key %s is already assigned and not of type table array", key) p.raiseError(key, "key %s is already assigned and not of type group array", key)
} }
p.currentTable = keys p.currentGroup = keys
// add a new tree to the end of the table array // add a new tree to the end of the group array
newTree := newTomlTree() newTree := newTomlTree()
newTree.position = startToken.Position newTree.position = startToken.Position
array = append(array, newTree) array = append(array, newTree)
p.tree.SetPath(p.currentTable, array) p.tree.SetPath(p.currentGroup, array)
// remove all keys that were children of this table array // remove all keys that were children of this group array
prefix := key.val + "." prefix := key.val + "."
found := false found := false
for ii := 0; ii < len(p.seenTableKeys); { for ii := 0; ii < len(p.seenGroupKeys); {
tableKey := p.seenTableKeys[ii] groupKey := p.seenGroupKeys[ii]
if strings.HasPrefix(tableKey, prefix) { if strings.HasPrefix(groupKey, prefix) {
p.seenTableKeys = append(p.seenTableKeys[:ii], p.seenTableKeys[ii+1:]...) p.seenGroupKeys = append(p.seenGroupKeys[:ii], p.seenGroupKeys[ii+1:]...)
} else { } else {
found = (tableKey == key.val) found = (groupKey == key.val)
ii++ ii++
} }
} }
// keep this key name from use by other kinds of assignments // keep this key name from use by other kinds of assignments
if !found { if !found {
p.seenTableKeys = append(p.seenTableKeys, key.val) p.seenGroupKeys = append(p.seenGroupKeys, key.val)
} }
// move to next parser state // move to next parser state
@ -149,24 +148,24 @@ func (p *tomlParser) parseGroup() tomlParserStateFn {
startToken := p.getToken() // discard the [ startToken := p.getToken() // discard the [
key := p.getToken() key := p.getToken()
if key.typ != tokenKeyGroup { if key.typ != tokenKeyGroup {
p.raiseError(key, "unexpected token %s, was expecting a table key", key) p.raiseError(key, "unexpected token %s, was expecting a key group", key)
} }
for _, item := range p.seenTableKeys { for _, item := range p.seenGroupKeys {
if item == key.val { if item == key.val {
p.raiseError(key, "duplicated tables") p.raiseError(key, "duplicated tables")
} }
} }
p.seenTableKeys = append(p.seenTableKeys, key.val) p.seenGroupKeys = append(p.seenGroupKeys, key.val)
keys, err := parseKey(key.val) keys, err := parseKey(key.val)
if err != nil { if err != nil {
p.raiseError(key, "invalid table array key: %s", err) p.raiseError(key, "invalid group array key: %s", err)
} }
if err := p.tree.createSubTree(keys, startToken.Position); err != nil { if err := p.tree.createSubTree(keys, startToken.Position); err != nil {
p.raiseError(key, "%s", err) p.raiseError(key, "%s", err)
} }
p.assume(tokenRightBracket) p.assume(tokenRightBracket)
p.currentTable = keys p.currentGroup = keys
return p.parseStart return p.parseStart
} }
@ -175,26 +174,26 @@ func (p *tomlParser) parseAssign() tomlParserStateFn {
p.assume(tokenEqual) p.assume(tokenEqual)
value := p.parseRvalue() value := p.parseRvalue()
var tableKey []string var groupKey []string
if len(p.currentTable) > 0 { if len(p.currentGroup) > 0 {
tableKey = p.currentTable groupKey = p.currentGroup
} else { } else {
tableKey = []string{} groupKey = []string{}
} }
// find the table to assign, looking out for arrays of tables // find the group to assign, looking out for arrays of groups
var targetNode *TomlTree var targetNode *TomlTree
switch node := p.tree.GetPath(tableKey).(type) { switch node := p.tree.GetPath(groupKey).(type) {
case []*TomlTree: case []*TomlTree:
targetNode = node[len(node)-1] targetNode = node[len(node)-1]
case *TomlTree: case *TomlTree:
targetNode = node targetNode = node
default: default:
p.raiseError(key, "Unknown table type for path: %s", p.raiseError(key, "Unknown group type for path: %s",
strings.Join(tableKey, ".")) strings.Join(groupKey, "."))
} }
// assign value to the found table // assign value to the found group
keyVals, err := parseKey(key.val) keyVals, err := parseKey(key.val)
if err != nil { if err != nil {
p.raiseError(key, "%s", err) p.raiseError(key, "%s", err)
@ -204,7 +203,7 @@ func (p *tomlParser) parseAssign() tomlParserStateFn {
} }
keyVal := keyVals[0] keyVal := keyVals[0]
localKey := []string{keyVal} localKey := []string{keyVal}
finalKey := append(tableKey, keyVal) finalKey := append(groupKey, keyVal)
if targetNode.GetPath(localKey) != nil { if targetNode.GetPath(localKey) != nil {
p.raiseError(key, "The following key was defined twice: %s", p.raiseError(key, "The following key was defined twice: %s",
strings.Join(finalKey, ".")) strings.Join(finalKey, "."))
@ -212,7 +211,7 @@ func (p *tomlParser) parseAssign() tomlParserStateFn {
var toInsert interface{} var toInsert interface{}
switch value.(type) { switch value.(type) {
case *TomlTree, []*TomlTree: case *TomlTree:
toInsert = value toInsert = value
default: default:
toInsert = &tomlValue{value, key.Position} toInsert = &tomlValue{value, key.Position}
@ -225,7 +224,7 @@ var numberUnderscoreInvalidRegexp *regexp.Regexp
func cleanupNumberToken(value string) (string, error) { func cleanupNumberToken(value string) (string, error) {
if numberUnderscoreInvalidRegexp.MatchString(value) { if numberUnderscoreInvalidRegexp.MatchString(value) {
return "", errors.New("invalid use of _ in number") return "", fmt.Errorf("invalid use of _ in number")
} }
cleanedVal := strings.Replace(value, "_", "", -1) cleanedVal := strings.Replace(value, "_", "", -1)
return cleanedVal, nil return cleanedVal, nil
@ -381,8 +380,8 @@ func parseToml(flow chan token) *TomlTree {
flow: flow, flow: flow,
tree: result, tree: result,
tokensBuffer: make([]token, 0), tokensBuffer: make([]token, 0),
currentTable: make([]string, 0), currentGroup: make([]string, 0),
seenTableKeys: make([]string, 0), seenGroupKeys: make([]string, 0),
} }
parser.run() parser.run()
return result return result

View File

@ -18,12 +18,12 @@ type Position struct {
// String representation of the position. // String representation of the position.
// Displays 1-indexed line and column numbers. // Displays 1-indexed line and column numbers.
func (p Position) String() string { func (p *Position) String() string {
return fmt.Sprintf("(%d, %d)", p.Line, p.Col) return fmt.Sprintf("(%d, %d)", p.Line, p.Col)
} }
// Invalid returns whether or not the position is valid (i.e. with negative or // Invalid returns whether or not the position is valid (i.e. with negative or
// null values) // null values)
func (p Position) Invalid() bool { func (p *Position) Invalid() bool {
return p.Line <= 0 || p.Col <= 0 return p.Line <= 0 || p.Col <= 0
} }

View File

@ -30,7 +30,7 @@ func (r *QueryResult) appendResult(node interface{}, pos Position) {
// Values is a set of values within a QueryResult. The order of values is not // Values is a set of values within a QueryResult. The order of values is not
// guaranteed to be in document order, and may be different each time a query is // guaranteed to be in document order, and may be different each time a query is
// executed. // executed.
func (r QueryResult) Values() []interface{} { func (r *QueryResult) Values() []interface{} {
values := make([]interface{}, len(r.items)) values := make([]interface{}, len(r.items))
for i, v := range r.items { for i, v := range r.items {
o, ok := v.(*tomlValue) o, ok := v.(*tomlValue)
@ -45,7 +45,7 @@ func (r QueryResult) Values() []interface{} {
// Positions is a set of positions for values within a QueryResult. Each index // Positions is a set of positions for values within a QueryResult. Each index
// in Positions() corresponds to the entry in Value() of the same index. // in Positions() corresponds to the entry in Value() of the same index.
func (r QueryResult) Positions() []Position { func (r *QueryResult) Positions() []Position {
return r.positions return r.positions
} }

View File

@ -272,23 +272,6 @@ func (l *queryLexer) lexString() queryLexStateFn {
return l.errorf("invalid unicode escape: \\u" + code) return l.errorf("invalid unicode escape: \\u" + code)
} }
growingString += string(rune(intcode)) growingString += string(rune(intcode))
} else if l.follow("\\U") {
l.pos += 2
code := ""
for i := 0; i < 8; i++ {
c := l.peek()
l.pos++
if !isHexDigit(c) {
return l.errorf("unfinished unicode escape")
}
code = code + string(c)
}
l.pos--
intcode, err := strconv.ParseInt(code, 16, 32)
if err != nil {
return l.errorf("invalid unicode escape: \\u" + code)
}
growingString += string(rune(intcode))
} else if l.follow("\\") { } else if l.follow("\\") {
l.pos++ l.pos++
return l.errorf("invalid escape sequence: \\" + string(l.peek())) return l.errorf("invalid escape sequence: \\" + string(l.peek()))

View File

@ -135,6 +135,5 @@ func isDigit(r rune) bool {
func isHexDigit(r rune) bool { func isHexDigit(r rune) bool {
return isDigit(r) || return isDigit(r) ||
(r >= 'a' && r <= 'f') || r == 'A' || r == 'B' || r == 'C' || r == 'D' || r == 'E' || r == 'F'
(r >= 'A' && r <= 'F')
} }

View File

@ -10,13 +10,13 @@ import (
) )
type tomlValue struct { type tomlValue struct {
value interface{} // string, int64, uint64, float64, bool, time.Time, [] of any of this list value interface{}
position Position position Position
} }
// TomlTree is the result of the parsing of a TOML file. // TomlTree is the result of the parsing of a TOML file.
type TomlTree struct { type TomlTree struct {
values map[string]interface{} // string -> *tomlValue, *TomlTree, []*TomlTree values map[string]interface{}
position Position position Position
} }
@ -28,12 +28,10 @@ func newTomlTree() *TomlTree {
} }
// TreeFromMap initializes a new TomlTree object using the given map. // TreeFromMap initializes a new TomlTree object using the given map.
func TreeFromMap(m map[string]interface{}) (*TomlTree, error) { func TreeFromMap(m map[string]interface{}) *TomlTree {
result, err := toTree(m) return &TomlTree{
if err != nil { values: m,
return nil, err
} }
return result.(*TomlTree), nil
} }
// Has returns a boolean indicating if the given key exists. // Has returns a boolean indicating if the given key exists.
@ -224,6 +222,9 @@ func (t *TomlTree) SetPath(keys []string, value interface{}) {
func (t *TomlTree) createSubTree(keys []string, pos Position) error { func (t *TomlTree) createSubTree(keys []string, pos Position) error {
subtree := t subtree := t
for _, intermediateKey := range keys { for _, intermediateKey := range keys {
if intermediateKey == "" {
return fmt.Errorf("empty intermediate table")
}
nextTree, exists := subtree.values[intermediateKey] nextTree, exists := subtree.values[intermediateKey]
if !exists { if !exists {
tree := newTomlTree() tree := newTomlTree()

View File

@ -0,0 +1,144 @@
// Tools to convert a TomlTree to different representations
package toml
import (
"fmt"
"strconv"
"strings"
"time"
)
// encodes a string to a TOML-compliant string value
func encodeTomlString(value string) string {
result := ""
for _, rr := range value {
intRr := uint16(rr)
switch rr {
case '\b':
result += "\\b"
case '\t':
result += "\\t"
case '\n':
result += "\\n"
case '\f':
result += "\\f"
case '\r':
result += "\\r"
case '"':
result += "\\\""
case '\\':
result += "\\\\"
default:
if intRr < 0x001F {
result += fmt.Sprintf("\\u%0.4X", intRr)
} else {
result += string(rr)
}
}
}
return result
}
// Value print support function for ToString()
// Outputs the TOML compliant string representation of a value
func toTomlValue(item interface{}, indent int) string {
tab := strings.Repeat(" ", indent)
switch value := item.(type) {
case int64:
return tab + strconv.FormatInt(value, 10)
case float64:
return tab + strconv.FormatFloat(value, 'f', -1, 64)
case string:
return tab + "\"" + encodeTomlString(value) + "\""
case bool:
if value {
return "true"
}
return "false"
case time.Time:
return tab + value.Format(time.RFC3339)
case []interface{}:
result := tab + "[\n"
for _, item := range value {
result += toTomlValue(item, indent+2) + ",\n"
}
return result + tab + "]"
default:
panic(fmt.Sprintf("unsupported value type: %v", value))
}
}
// Recursive support function for ToString()
// Outputs a tree, using the provided keyspace to prefix group names
func (t *TomlTree) toToml(indent, keyspace string) string {
result := ""
for k, v := range t.values {
// figure out the keyspace
combinedKey := k
if keyspace != "" {
combinedKey = keyspace + "." + combinedKey
}
// output based on type
switch node := v.(type) {
case []*TomlTree:
for _, item := range node {
if len(item.Keys()) > 0 {
result += fmt.Sprintf("\n%s[[%s]]\n", indent, combinedKey)
}
result += item.toToml(indent+" ", combinedKey)
}
case *TomlTree:
if len(node.Keys()) > 0 {
result += fmt.Sprintf("\n%s[%s]\n", indent, combinedKey)
}
result += node.toToml(indent+" ", combinedKey)
case map[string]interface{}:
sub := TreeFromMap(node)
if len(sub.Keys()) > 0 {
result += fmt.Sprintf("\n%s[%s]\n", indent, combinedKey)
}
result += sub.toToml(indent+" ", combinedKey)
case *tomlValue:
result += fmt.Sprintf("%s%s = %s\n", indent, k, toTomlValue(node.value, 0))
default:
result += fmt.Sprintf("%s%s = %s\n", indent, k, toTomlValue(v, 0))
}
}
return result
}
// ToString is an alias for String
func (t *TomlTree) ToString() string {
return t.String()
}
// ToString generates a human-readable representation of the current tree.
// Output spans multiple lines, and is suitable for ingest by a TOML parser
func (t *TomlTree) String() string {
return t.toToml("", "")
}
// ToMap recursively generates a representation of the current tree using map[string]interface{}.
func (t *TomlTree) ToMap() map[string]interface{} {
result := map[string]interface{}{}
for k, v := range t.values {
switch node := v.(type) {
case []*TomlTree:
result[k] = make([]interface{}, 0)
for _, item := range node {
result[k] = item.ToMap()
}
case *TomlTree:
result[k] = node.ToMap()
case map[string]interface{}:
sub := TreeFromMap(node)
result[k] = sub.ToMap()
case *tomlValue:
result[k] = node.value
}
}
return result
}

View File

@ -1,129 +0,0 @@
package toml
import (
"fmt"
"reflect"
"time"
)
// supported values:
// string, bool, int64, uint64, float64, time.Time, int, int8, int16, int32, uint, uint8, uint16, uint32, float32
var kindToTypeMapping = map[reflect.Kind]reflect.Type{
reflect.Bool: reflect.TypeOf(true),
reflect.String: reflect.TypeOf(""),
reflect.Float32: reflect.TypeOf(float64(1)),
reflect.Float64: reflect.TypeOf(float64(1)),
reflect.Int: reflect.TypeOf(int64(1)),
reflect.Int8: reflect.TypeOf(int64(1)),
reflect.Int16: reflect.TypeOf(int64(1)),
reflect.Int32: reflect.TypeOf(int64(1)),
reflect.Int64: reflect.TypeOf(int64(1)),
reflect.Uint: reflect.TypeOf(uint64(1)),
reflect.Uint8: reflect.TypeOf(uint64(1)),
reflect.Uint16: reflect.TypeOf(uint64(1)),
reflect.Uint32: reflect.TypeOf(uint64(1)),
reflect.Uint64: reflect.TypeOf(uint64(1)),
}
func simpleValueCoercion(object interface{}) (interface{}, error) {
switch original := object.(type) {
case string, bool, int64, uint64, float64, time.Time:
return original, nil
case int:
return int64(original), nil
case int8:
return int64(original), nil
case int16:
return int64(original), nil
case int32:
return int64(original), nil
case uint:
return uint64(original), nil
case uint8:
return uint64(original), nil
case uint16:
return uint64(original), nil
case uint32:
return uint64(original), nil
case float32:
return float64(original), nil
default:
return nil, fmt.Errorf("cannot convert type %T to TomlTree", object)
}
}
func sliceToTree(object interface{}) (interface{}, error) {
// arrays are a bit tricky, since they can represent either a
// collection of simple values, which is represented by one
// *tomlValue, or an array of tables, which is represented by an
// array of *TomlTree.
// holding the assumption that this function is called from toTree only when value.Kind() is Array or Slice
value := reflect.ValueOf(object)
insideType := value.Type().Elem()
length := value.Len()
if insideType.Kind() == reflect.Map {
// this is considered as an array of tables
tablesArray := make([]*TomlTree, 0, length)
for i := 0; i < length; i++ {
table := value.Index(i)
tree, err := toTree(table.Interface())
if err != nil {
return nil, err
}
tablesArray = append(tablesArray, tree.(*TomlTree))
}
return tablesArray, nil
}
sliceType := kindToTypeMapping[insideType.Kind()]
if sliceType == nil {
sliceType = insideType
}
arrayValue := reflect.MakeSlice(reflect.SliceOf(sliceType), 0, length)
for i := 0; i < length; i++ {
val := value.Index(i).Interface()
simpleValue, err := simpleValueCoercion(val)
if err != nil {
return nil, err
}
arrayValue = reflect.Append(arrayValue, reflect.ValueOf(simpleValue))
}
return &tomlValue{arrayValue.Interface(), Position{}}, nil
}
func toTree(object interface{}) (interface{}, error) {
value := reflect.ValueOf(object)
if value.Kind() == reflect.Map {
values := map[string]interface{}{}
keys := value.MapKeys()
for _, key := range keys {
k, ok := key.Interface().(string)
if !ok {
return nil, fmt.Errorf("map key needs to be a string, not %T", key.Interface())
}
v := value.MapIndex(key)
newValue, err := toTree(v.Interface())
if err != nil {
return nil, err
}
values[k] = newValue
}
return &TomlTree{values, Position{}}, nil
}
if value.Kind() == reflect.Array || value.Kind() == reflect.Slice {
return sliceToTree(object)
}
simpleValue, err := simpleValueCoercion(object)
if err != nil {
return nil, err
}
return &tomlValue{simpleValue, Position{}}, nil
}

View File

@ -1,209 +0,0 @@
package toml
import (
"bytes"
"fmt"
"io"
"sort"
"strconv"
"strings"
"time"
)
// encodes a string to a TOML-compliant string value
func encodeTomlString(value string) string {
result := ""
for _, rr := range value {
switch rr {
case '\b':
result += "\\b"
case '\t':
result += "\\t"
case '\n':
result += "\\n"
case '\f':
result += "\\f"
case '\r':
result += "\\r"
case '"':
result += "\\\""
case '\\':
result += "\\\\"
default:
intRr := uint16(rr)
if intRr < 0x001F {
result += fmt.Sprintf("\\u%0.4X", intRr)
} else {
result += string(rr)
}
}
}
return result
}
func tomlValueStringRepresentation(v interface{}) (string, error) {
switch value := v.(type) {
case uint64:
return strconv.FormatUint(value, 10), nil
case int64:
return strconv.FormatInt(value, 10), nil
case float64:
return strconv.FormatFloat(value, 'f', -1, 32), nil
case string:
return "\"" + encodeTomlString(value) + "\"", nil
case bool:
if value {
return "true", nil
}
return "false", nil
case time.Time:
return value.Format(time.RFC3339), nil
case nil:
return "", nil
case []interface{}:
values := []string{}
for _, item := range value {
itemRepr, err := tomlValueStringRepresentation(item)
if err != nil {
return "", err
}
values = append(values, itemRepr)
}
return "[" + strings.Join(values, ",") + "]", nil
default:
return "", fmt.Errorf("unsupported value type %T: %v", value, value)
}
}
func (t *TomlTree) writeTo(w io.Writer, indent, keyspace string, bytesCount int64) (int64, error) {
simpleValuesKeys := make([]string, 0)
complexValuesKeys := make([]string, 0)
for k := range t.values {
v := t.values[k]
switch v.(type) {
case *TomlTree, []*TomlTree:
complexValuesKeys = append(complexValuesKeys, k)
default:
simpleValuesKeys = append(simpleValuesKeys, k)
}
}
sort.Strings(simpleValuesKeys)
sort.Strings(complexValuesKeys)
for _, k := range simpleValuesKeys {
v, ok := t.values[k].(*tomlValue)
if !ok {
return bytesCount, fmt.Errorf("invalid value type at %s: %T", k, t.values[k])
}
repr, err := tomlValueStringRepresentation(v.value)
if err != nil {
return bytesCount, err
}
kvRepr := fmt.Sprintf("%s%s = %s\n", indent, k, repr)
writtenBytesCount, err := w.Write([]byte(kvRepr))
bytesCount += int64(writtenBytesCount)
if err != nil {
return bytesCount, err
}
}
for _, k := range complexValuesKeys {
v := t.values[k]
combinedKey := k
if keyspace != "" {
combinedKey = keyspace + "." + combinedKey
}
switch node := v.(type) {
// node has to be of those two types given how keys are sorted above
case *TomlTree:
tableName := fmt.Sprintf("\n%s[%s]\n", indent, combinedKey)
writtenBytesCount, err := w.Write([]byte(tableName))
bytesCount += int64(writtenBytesCount)
if err != nil {
return bytesCount, err
}
bytesCount, err = node.writeTo(w, indent+" ", combinedKey, bytesCount)
if err != nil {
return bytesCount, err
}
case []*TomlTree:
for _, subTree := range node {
if len(subTree.values) > 0 {
tableArrayName := fmt.Sprintf("\n%s[[%s]]\n", indent, combinedKey)
writtenBytesCount, err := w.Write([]byte(tableArrayName))
bytesCount += int64(writtenBytesCount)
if err != nil {
return bytesCount, err
}
bytesCount, err = subTree.writeTo(w, indent+" ", combinedKey, bytesCount)
if err != nil {
return bytesCount, err
}
}
}
}
}
return bytesCount, nil
}
// WriteTo encode the TomlTree as Toml and writes it to the writer w.
// Returns the number of bytes written in case of success, or an error if anything happened.
func (t *TomlTree) WriteTo(w io.Writer) (int64, error) {
return t.writeTo(w, "", "", 0)
}
// ToTomlString generates a human-readable representation of the current tree.
// Output spans multiple lines, and is suitable for ingest by a TOML parser.
// If the conversion cannot be performed, ToString returns a non-nil error.
func (t *TomlTree) ToTomlString() (string, error) {
var buf bytes.Buffer
_, err := t.WriteTo(&buf)
if err != nil {
return "", err
}
return buf.String(), nil
}
// String generates a human-readable representation of the current tree.
// Alias of ToString. Present to implement the fmt.Stringer interface.
func (t *TomlTree) String() string {
result, _ := t.ToTomlString()
return result
}
// ToMap recursively generates a representation of the tree using Go built-in structures.
// The following types are used:
// * uint64
// * int64
// * bool
// * string
// * time.Time
// * map[string]interface{} (where interface{} is any of this list)
// * []interface{} (where interface{} is any of this list)
func (t *TomlTree) ToMap() map[string]interface{} {
result := map[string]interface{}{}
for k, v := range t.values {
switch node := v.(type) {
case []*TomlTree:
var array []interface{}
for _, item := range node {
array = append(array, item.ToMap())
}
result[k] = array
case *TomlTree:
result[k] = node.ToMap()
case *tomlValue:
result[k] = node.value
}
}
return result
}

View File

@ -52,7 +52,7 @@ func validateBasePathName(name string) error {
// On Windows a common mistake would be to provide an absolute OS path // On Windows a common mistake would be to provide an absolute OS path
// We could strip out the base part, but that would not be very portable. // We could strip out the base part, but that would not be very portable.
if filepath.IsAbs(name) { if filepath.IsAbs(name) {
return &os.PathError{Op: "realPath", Path: name, Err: errors.New("got a real OS path instead of a virtual")} return &os.PathError{"realPath", name, errors.New("got a real OS path instead of a virtual")}
} }
return nil return nil
@ -60,14 +60,14 @@ func validateBasePathName(name string) error {
func (b *BasePathFs) Chtimes(name string, atime, mtime time.Time) (err error) { func (b *BasePathFs) Chtimes(name string, atime, mtime time.Time) (err error) {
if name, err = b.RealPath(name); err != nil { if name, err = b.RealPath(name); err != nil {
return &os.PathError{Op: "chtimes", Path: name, Err: err} return &os.PathError{"chtimes", name, err}
} }
return b.source.Chtimes(name, atime, mtime) return b.source.Chtimes(name, atime, mtime)
} }
func (b *BasePathFs) Chmod(name string, mode os.FileMode) (err error) { func (b *BasePathFs) Chmod(name string, mode os.FileMode) (err error) {
if name, err = b.RealPath(name); err != nil { if name, err = b.RealPath(name); err != nil {
return &os.PathError{Op: "chmod", Path: name, Err: err} return &os.PathError{"chmod", name, err}
} }
return b.source.Chmod(name, mode) return b.source.Chmod(name, mode)
} }
@ -78,66 +78,66 @@ func (b *BasePathFs) Name() string {
func (b *BasePathFs) Stat(name string) (fi os.FileInfo, err error) { func (b *BasePathFs) Stat(name string) (fi os.FileInfo, err error) {
if name, err = b.RealPath(name); err != nil { if name, err = b.RealPath(name); err != nil {
return nil, &os.PathError{Op: "stat", Path: name, Err: err} return nil, &os.PathError{"stat", name, err}
} }
return b.source.Stat(name) return b.source.Stat(name)
} }
func (b *BasePathFs) Rename(oldname, newname string) (err error) { func (b *BasePathFs) Rename(oldname, newname string) (err error) {
if oldname, err = b.RealPath(oldname); err != nil { if oldname, err = b.RealPath(oldname); err != nil {
return &os.PathError{Op: "rename", Path: oldname, Err: err} return &os.PathError{"rename", oldname, err}
} }
if newname, err = b.RealPath(newname); err != nil { if newname, err = b.RealPath(newname); err != nil {
return &os.PathError{Op: "rename", Path: newname, Err: err} return &os.PathError{"rename", newname, err}
} }
return b.source.Rename(oldname, newname) return b.source.Rename(oldname, newname)
} }
func (b *BasePathFs) RemoveAll(name string) (err error) { func (b *BasePathFs) RemoveAll(name string) (err error) {
if name, err = b.RealPath(name); err != nil { if name, err = b.RealPath(name); err != nil {
return &os.PathError{Op: "remove_all", Path: name, Err: err} return &os.PathError{"remove_all", name, err}
} }
return b.source.RemoveAll(name) return b.source.RemoveAll(name)
} }
func (b *BasePathFs) Remove(name string) (err error) { func (b *BasePathFs) Remove(name string) (err error) {
if name, err = b.RealPath(name); err != nil { if name, err = b.RealPath(name); err != nil {
return &os.PathError{Op: "remove", Path: name, Err: err} return &os.PathError{"remove", name, err}
} }
return b.source.Remove(name) return b.source.Remove(name)
} }
func (b *BasePathFs) OpenFile(name string, flag int, mode os.FileMode) (f File, err error) { func (b *BasePathFs) OpenFile(name string, flag int, mode os.FileMode) (f File, err error) {
if name, err = b.RealPath(name); err != nil { if name, err = b.RealPath(name); err != nil {
return nil, &os.PathError{Op: "openfile", Path: name, Err: err} return nil, &os.PathError{"openfile", name, err}
} }
return b.source.OpenFile(name, flag, mode) return b.source.OpenFile(name, flag, mode)
} }
func (b *BasePathFs) Open(name string) (f File, err error) { func (b *BasePathFs) Open(name string) (f File, err error) {
if name, err = b.RealPath(name); err != nil { if name, err = b.RealPath(name); err != nil {
return nil, &os.PathError{Op: "open", Path: name, Err: err} return nil, &os.PathError{"open", name, err}
} }
return b.source.Open(name) return b.source.Open(name)
} }
func (b *BasePathFs) Mkdir(name string, mode os.FileMode) (err error) { func (b *BasePathFs) Mkdir(name string, mode os.FileMode) (err error) {
if name, err = b.RealPath(name); err != nil { if name, err = b.RealPath(name); err != nil {
return &os.PathError{Op: "mkdir", Path: name, Err: err} return &os.PathError{"mkdir", name, err}
} }
return b.source.Mkdir(name, mode) return b.source.Mkdir(name, mode)
} }
func (b *BasePathFs) MkdirAll(name string, mode os.FileMode) (err error) { func (b *BasePathFs) MkdirAll(name string, mode os.FileMode) (err error) {
if name, err = b.RealPath(name); err != nil { if name, err = b.RealPath(name); err != nil {
return &os.PathError{Op: "mkdir", Path: name, Err: err} return &os.PathError{"mkdir", name, err}
} }
return b.source.MkdirAll(name, mode) return b.source.MkdirAll(name, mode)
} }
func (b *BasePathFs) Create(name string) (f File, err error) { func (b *BasePathFs) Create(name string) (f File, err error) {
if name, err = b.RealPath(name); err != nil { if name, err = b.RealPath(name); err != nil {
return nil, &os.PathError{Op: "create", Path: name, Err: err} return nil, &os.PathError{"create", name, err}
} }
return b.source.Create(name) return b.source.Create(name)
} }

View File

@ -32,8 +32,9 @@ func NewCacheOnReadFs(base Fs, layer Fs, cacheTime time.Duration) Fs {
type cacheState int type cacheState int
const ( const (
cacheUnknown cacheState = iota
// not present in the overlay, unknown if it exists in the base: // not present in the overlay, unknown if it exists in the base:
cacheMiss cacheState = iota cacheMiss
// present in the overlay and in base, base file is newer: // present in the overlay and in base, base file is newer:
cacheStale cacheStale
// present in the overlay - with cache time == 0 it may exist in the base, // present in the overlay - with cache time == 0 it may exist in the base,

View File

@ -186,7 +186,7 @@ func (f *File) Truncate(size int64) error {
return ErrFileClosed return ErrFileClosed
} }
if f.readOnly { if f.readOnly {
return &os.PathError{Op: "truncate", Path: f.fileData.name, Err: errors.New("file handle is read only")} return &os.PathError{"truncate", f.fileData.name, errors.New("file handle is read only")}
} }
if size < 0 { if size < 0 {
return ErrOutOfRange return ErrOutOfRange
@ -218,7 +218,7 @@ func (f *File) Seek(offset int64, whence int) (int64, error) {
func (f *File) Write(b []byte) (n int, err error) { func (f *File) Write(b []byte) (n int, err error) {
if f.readOnly { if f.readOnly {
return 0, &os.PathError{Op: "write", Path: f.fileData.name, Err: errors.New("file handle is read only")} return 0, &os.PathError{"write", f.fileData.name, errors.New("file handle is read only")}
} }
n = len(b) n = len(b)
cur := atomic.LoadInt64(&f.at) cur := atomic.LoadInt64(&f.at)

View File

@ -35,6 +35,8 @@ func NewMemMapFs() Fs {
return &MemMapFs{} return &MemMapFs{}
} }
var memfsInit sync.Once
func (m *MemMapFs) getData() map[string]*mem.FileData { func (m *MemMapFs) getData() map[string]*mem.FileData {
m.init.Do(func() { m.init.Do(func() {
m.data = make(map[string]*mem.FileData) m.data = make(map[string]*mem.FileData)
@ -45,7 +47,7 @@ func (m *MemMapFs) getData() map[string]*mem.FileData {
return m.data return m.data
} }
func (*MemMapFs) Name() string { return "MemMapFS" } func (MemMapFs) Name() string { return "MemMapFS" }
func (m *MemMapFs) Create(name string) (File, error) { func (m *MemMapFs) Create(name string) (File, error) {
name = normalizePath(name) name = normalizePath(name)
@ -108,7 +110,7 @@ func (m *MemMapFs) lockfreeMkdir(name string, perm os.FileMode) error {
x, ok := m.getData()[name] x, ok := m.getData()[name]
if ok { if ok {
// Only return ErrFileExists if it's a file, not a directory. // Only return ErrFileExists if it's a file, not a directory.
i := mem.FileInfo{FileData: x} i := mem.FileInfo{x}
if !i.IsDir() { if !i.IsDir() {
return ErrFileExists return ErrFileExists
} }
@ -127,17 +129,14 @@ func (m *MemMapFs) Mkdir(name string, perm os.FileMode) error {
_, ok := m.getData()[name] _, ok := m.getData()[name]
m.mu.RUnlock() m.mu.RUnlock()
if ok { if ok {
return &os.PathError{Op: "mkdir", Path: name, Err: ErrFileExists} return &os.PathError{"mkdir", name, ErrFileExists}
} else {
m.mu.Lock()
item := mem.CreateDir(name)
m.getData()[name] = item
m.registerWithParent(item)
m.mu.Unlock()
} }
m.mu.Lock()
item := mem.CreateDir(name)
m.getData()[name] = item
m.registerWithParent(item)
m.mu.Unlock()
m.Chmod(name, perm)
return nil return nil
} }
@ -190,7 +189,7 @@ func (m *MemMapFs) open(name string) (*mem.FileData, error) {
f, ok := m.getData()[name] f, ok := m.getData()[name]
m.mu.RUnlock() m.mu.RUnlock()
if !ok { if !ok {
return nil, &os.PathError{Op: "open", Path: name, Err: ErrFileNotFound} return nil, &os.PathError{"open", name, ErrFileNotFound}
} }
return f, nil return f, nil
} }
@ -206,11 +205,9 @@ func (m *MemMapFs) lockfreeOpen(name string) (*mem.FileData, error) {
} }
func (m *MemMapFs) OpenFile(name string, flag int, perm os.FileMode) (File, error) { func (m *MemMapFs) OpenFile(name string, flag int, perm os.FileMode) (File, error) {
chmod := false
file, err := m.openWrite(name) file, err := m.openWrite(name)
if os.IsNotExist(err) && (flag&os.O_CREATE > 0) { if os.IsNotExist(err) && (flag&os.O_CREATE > 0) {
file, err = m.Create(name) file, err = m.Create(name)
chmod = true
} }
if err != nil { if err != nil {
return nil, err return nil, err
@ -232,9 +229,6 @@ func (m *MemMapFs) OpenFile(name string, flag int, perm os.FileMode) (File, erro
return nil, err return nil, err
} }
} }
if chmod {
m.Chmod(name, perm)
}
return file, nil return file, nil
} }
@ -247,11 +241,11 @@ func (m *MemMapFs) Remove(name string) error {
if _, ok := m.getData()[name]; ok { if _, ok := m.getData()[name]; ok {
err := m.unRegisterWithParent(name) err := m.unRegisterWithParent(name)
if err != nil { if err != nil {
return &os.PathError{Op: "remove", Path: name, Err: err} return &os.PathError{"remove", name, err}
} }
delete(m.getData(), name) delete(m.getData(), name)
} else { } else {
return &os.PathError{Op: "remove", Path: name, Err: os.ErrNotExist} return &os.PathError{"remove", name, os.ErrNotExist}
} }
return nil return nil
} }
@ -299,7 +293,7 @@ func (m *MemMapFs) Rename(oldname, newname string) error {
m.mu.Unlock() m.mu.Unlock()
m.mu.RLock() m.mu.RLock()
} else { } else {
return &os.PathError{Op: "rename", Path: oldname, Err: ErrFileNotFound} return &os.PathError{"rename", oldname, ErrFileNotFound}
} }
return nil return nil
} }
@ -315,12 +309,9 @@ func (m *MemMapFs) Stat(name string) (os.FileInfo, error) {
func (m *MemMapFs) Chmod(name string, mode os.FileMode) error { func (m *MemMapFs) Chmod(name string, mode os.FileMode) error {
name = normalizePath(name) name = normalizePath(name)
m.mu.RLock()
f, ok := m.getData()[name] f, ok := m.getData()[name]
m.mu.RUnlock()
if !ok { if !ok {
return &os.PathError{Op: "chmod", Path: name, Err: ErrFileNotFound} return &os.PathError{"chmod", name, ErrFileNotFound}
} }
m.mu.Lock() m.mu.Lock()
@ -332,12 +323,9 @@ func (m *MemMapFs) Chmod(name string, mode os.FileMode) error {
func (m *MemMapFs) Chtimes(name string, atime time.Time, mtime time.Time) error { func (m *MemMapFs) Chtimes(name string, atime time.Time, mtime time.Time) error {
name = normalizePath(name) name = normalizePath(name)
m.mu.RLock()
f, ok := m.getData()[name] f, ok := m.getData()[name]
m.mu.RUnlock()
if !ok { if !ok {
return &os.PathError{Op: "chtimes", Path: name, Err: ErrFileNotFound} return &os.PathError{"chtimes", name, ErrFileNotFound}
} }
m.mu.Lock() m.mu.Lock()
@ -349,13 +337,13 @@ func (m *MemMapFs) Chtimes(name string, atime time.Time, mtime time.Time) error
func (m *MemMapFs) List() { func (m *MemMapFs) List() {
for _, x := range m.data { for _, x := range m.data {
y := mem.FileInfo{FileData: x} y := mem.FileInfo{x}
fmt.Println(x.Name(), y.Size()) fmt.Println(x.Name(), y.Size())
} }
} }
// func debugMemMapList(fs Fs) { func debugMemMapList(fs Fs) {
// if x, ok := fs.(*MemMapFs); ok { if x, ok := fs.(*MemMapFs); ok {
// x.List() x.List()
// } }
// } }

70
vendor/github.com/spf13/cast/cast.go generated vendored
View File

@ -3,150 +3,80 @@
// Use of this source code is governed by an MIT-style // Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
// Package cast provides easy and safe casting in Go.
package cast package cast
import "time" import "time"
// ToBool casts an interface to a bool type.
func ToBool(i interface{}) bool { func ToBool(i interface{}) bool {
v, _ := ToBoolE(i) v, _ := ToBoolE(i)
return v return v
} }
// ToTime casts an interface to a time.Time type.
func ToTime(i interface{}) time.Time { func ToTime(i interface{}) time.Time {
v, _ := ToTimeE(i) v, _ := ToTimeE(i)
return v return v
} }
// ToDuration casts an interface to a time.Duration type.
func ToDuration(i interface{}) time.Duration { func ToDuration(i interface{}) time.Duration {
v, _ := ToDurationE(i) v, _ := ToDurationE(i)
return v return v
} }
// ToFloat64 casts an interface to a float64 type.
func ToFloat64(i interface{}) float64 { func ToFloat64(i interface{}) float64 {
v, _ := ToFloat64E(i) v, _ := ToFloat64E(i)
return v return v
} }
// ToFloat32 casts an interface to a float32 type.
func ToFloat32(i interface{}) float32 {
v, _ := ToFloat32E(i)
return v
}
// ToInt64 casts an interface to an int64 type.
func ToInt64(i interface{}) int64 { func ToInt64(i interface{}) int64 {
v, _ := ToInt64E(i) v, _ := ToInt64E(i)
return v return v
} }
// ToInt32 casts an interface to an int32 type.
func ToInt32(i interface{}) int32 {
v, _ := ToInt32E(i)
return v
}
// ToInt16 casts an interface to an int16 type.
func ToInt16(i interface{}) int16 {
v, _ := ToInt16E(i)
return v
}
// ToInt8 casts an interface to an int8 type.
func ToInt8(i interface{}) int8 {
v, _ := ToInt8E(i)
return v
}
// ToInt casts an interface to an int type.
func ToInt(i interface{}) int { func ToInt(i interface{}) int {
v, _ := ToIntE(i) v, _ := ToIntE(i)
return v return v
} }
// ToUint casts an interface to a uint type.
func ToUint(i interface{}) uint {
v, _ := ToUintE(i)
return v
}
// ToUint64 casts an interface to a uint64 type.
func ToUint64(i interface{}) uint64 {
v, _ := ToUint64E(i)
return v
}
// ToUint32 casts an interface to a uint32 type.
func ToUint32(i interface{}) uint32 {
v, _ := ToUint32E(i)
return v
}
// ToUint16 casts an interface to a uint16 type.
func ToUint16(i interface{}) uint16 {
v, _ := ToUint16E(i)
return v
}
// ToUint8 casts an interface to a uint8 type.
func ToUint8(i interface{}) uint8 {
v, _ := ToUint8E(i)
return v
}
// ToString casts an interface to a string type.
func ToString(i interface{}) string { func ToString(i interface{}) string {
v, _ := ToStringE(i) v, _ := ToStringE(i)
return v return v
} }
// ToStringMapString casts an interface to a map[string]string type.
func ToStringMapString(i interface{}) map[string]string { func ToStringMapString(i interface{}) map[string]string {
v, _ := ToStringMapStringE(i) v, _ := ToStringMapStringE(i)
return v return v
} }
// ToStringMapStringSlice casts an interface to a map[string][]string type.
func ToStringMapStringSlice(i interface{}) map[string][]string { func ToStringMapStringSlice(i interface{}) map[string][]string {
v, _ := ToStringMapStringSliceE(i) v, _ := ToStringMapStringSliceE(i)
return v return v
} }
// ToStringMapBool casts an interface to a map[string]bool type.
func ToStringMapBool(i interface{}) map[string]bool { func ToStringMapBool(i interface{}) map[string]bool {
v, _ := ToStringMapBoolE(i) v, _ := ToStringMapBoolE(i)
return v return v
} }
// ToStringMap casts an interface to a map[string]interface{} type.
func ToStringMap(i interface{}) map[string]interface{} { func ToStringMap(i interface{}) map[string]interface{} {
v, _ := ToStringMapE(i) v, _ := ToStringMapE(i)
return v return v
} }
// ToSlice casts an interface to a []interface{} type.
func ToSlice(i interface{}) []interface{} { func ToSlice(i interface{}) []interface{} {
v, _ := ToSliceE(i) v, _ := ToSliceE(i)
return v return v
} }
// ToBoolSlice casts an interface to a []bool type.
func ToBoolSlice(i interface{}) []bool { func ToBoolSlice(i interface{}) []bool {
v, _ := ToBoolSliceE(i) v, _ := ToBoolSliceE(i)
return v return v
} }
// ToStringSlice casts an interface to a []string type.
func ToStringSlice(i interface{}) []string { func ToStringSlice(i interface{}) []string {
v, _ := ToStringSliceE(i) v, _ := ToStringSliceE(i)
return v return v
} }
// ToIntSlice casts an interface to a []int type.
func ToIntSlice(i interface{}) []int { func ToIntSlice(i interface{}) []int {
v, _ := ToIntSliceE(i) v, _ := ToIntSliceE(i)
return v return v

750
vendor/github.com/spf13/cast/caste.go generated vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,113 +0,0 @@
// Copyright © 2016 Steve Francia <spf@spf13.com>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package jwalterweatherman
import (
"io"
"io/ioutil"
"log"
"os"
)
var (
TRACE *log.Logger
DEBUG *log.Logger
INFO *log.Logger
WARN *log.Logger
ERROR *log.Logger
CRITICAL *log.Logger
FATAL *log.Logger
LOG *log.Logger
FEEDBACK *Feedback
defaultNotepad *Notepad
)
func reloadDefaultNotepad() {
TRACE = defaultNotepad.TRACE
DEBUG = defaultNotepad.DEBUG
INFO = defaultNotepad.INFO
WARN = defaultNotepad.WARN
ERROR = defaultNotepad.ERROR
CRITICAL = defaultNotepad.CRITICAL
FATAL = defaultNotepad.FATAL
LOG = defaultNotepad.LOG
FEEDBACK = defaultNotepad.FEEDBACK
}
func init() {
defaultNotepad = NewNotepad(LevelError, LevelWarn, os.Stdout, ioutil.Discard, "", log.Ldate|log.Ltime)
reloadDefaultNotepad()
}
// SetLogThreshold set the log threshold for the default notepad. Trace by default.
func SetLogThreshold(threshold Threshold) {
defaultNotepad.SetLogThreshold(threshold)
reloadDefaultNotepad()
}
// SetLogOutput set the log output for the default notepad. Discarded by default.
func SetLogOutput(handle io.Writer) {
defaultNotepad.SetLogOutput(handle)
reloadDefaultNotepad()
}
// SetStdoutThreshold set the standard output threshold for the default notepad.
// Info by default.
func SetStdoutThreshold(threshold Threshold) {
defaultNotepad.SetStdoutThreshold(threshold)
reloadDefaultNotepad()
}
// SetPrefix set the prefix for the default logger. Empty by default.
func SetPrefix(prefix string) {
defaultNotepad.SetPrefix(prefix)
reloadDefaultNotepad()
}
// SetFlags set the flags for the default logger. "log.Ldate | log.Ltime" by default.
func SetFlags(flags int) {
defaultNotepad.SetFlags(flags)
reloadDefaultNotepad()
}
// Level returns the current global log threshold.
func LogThreshold() Threshold {
return defaultNotepad.logThreshold
}
// Level returns the current global output threshold.
func StdoutThreshold() Threshold {
return defaultNotepad.stdoutThreshold
}
// GetStdoutThreshold returns the defined Treshold for the log logger.
func GetLogThreshold() Threshold {
return defaultNotepad.GetLogThreshold()
}
// GetStdoutThreshold returns the Treshold for the stdout logger.
func GetStdoutThreshold() Threshold {
return defaultNotepad.GetStdoutThreshold()
}
// LogCountForLevel returns the number of log invocations for a given threshold.
func LogCountForLevel(l Threshold) uint64 {
return defaultNotepad.LogCountForLevel(l)
}
// LogCountForLevelsGreaterThanorEqualTo returns the number of log invocations
// greater than or equal to a given threshold.
func LogCountForLevelsGreaterThanorEqualTo(threshold Threshold) uint64 {
return defaultNotepad.LogCountForLevelsGreaterThanorEqualTo(threshold)
}
// ResetLogCounters resets the invocation counters for all levels.
func ResetLogCounters() {
defaultNotepad.ResetLogCounters()
}

View File

@ -1,56 +0,0 @@
// Copyright © 2016 Steve Francia <spf@spf13.com>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package jwalterweatherman
import (
"sync/atomic"
)
type logCounter struct {
counter uint64
}
func (c *logCounter) incr() {
atomic.AddUint64(&c.counter, 1)
}
func (c *logCounter) resetCounter() {
atomic.StoreUint64(&c.counter, 0)
}
func (c *logCounter) getCount() uint64 {
return atomic.LoadUint64(&c.counter)
}
func (c *logCounter) Write(p []byte) (n int, err error) {
c.incr()
return len(p), nil
}
// LogCountForLevel returns the number of log invocations for a given threshold.
func (n *Notepad) LogCountForLevel(l Threshold) uint64 {
return n.logCounters[l].getCount()
}
// LogCountForLevelsGreaterThanorEqualTo returns the number of log invocations
// greater than or equal to a given threshold.
func (n *Notepad) LogCountForLevelsGreaterThanorEqualTo(threshold Threshold) uint64 {
var cnt uint64
for i := int(threshold); i < len(n.logCounters); i++ {
cnt += n.LogCountForLevel(Threshold(i))
}
return cnt
}
// ResetLogCounters resets the invocation counters for all levels.
func (n *Notepad) ResetLogCounters() {
for _, np := range n.logCounters {
np.resetCounter()
}
}

View File

@ -1,195 +0,0 @@
// Copyright © 2016 Steve Francia <spf@spf13.com>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package jwalterweatherman
import (
"fmt"
"io"
"log"
"os"
)
type Threshold int
func (t Threshold) String() string {
return prefixes[t]
}
const (
LevelTrace Threshold = iota
LevelDebug
LevelInfo
LevelWarn
LevelError
LevelCritical
LevelFatal
)
var prefixes map[Threshold]string = map[Threshold]string{
LevelTrace: "TRACE",
LevelDebug: "DEBUG",
LevelInfo: "INFO",
LevelWarn: "WARN",
LevelError: "ERROR",
LevelCritical: "CRITICAL",
LevelFatal: "FATAL",
}
func prefix(t Threshold) string {
return t.String() + " "
}
// Notepad is where you leave a note !
type Notepad struct {
TRACE *log.Logger
DEBUG *log.Logger
INFO *log.Logger
WARN *log.Logger
ERROR *log.Logger
CRITICAL *log.Logger
FATAL *log.Logger
LOG *log.Logger
FEEDBACK *Feedback
loggers []**log.Logger
logHandle io.Writer
outHandle io.Writer
logThreshold Threshold
stdoutThreshold Threshold
prefix string
flags int
// One per Threshold
logCounters [7]*logCounter
}
// NewNotepad create a new notepad.
func NewNotepad(outThreshold Threshold, logThreshold Threshold, outHandle, logHandle io.Writer, prefix string, flags int) *Notepad {
n := &Notepad{}
n.loggers = append(n.loggers, &n.TRACE, &n.DEBUG, &n.INFO, &n.WARN, &n.ERROR, &n.CRITICAL, &n.FATAL)
n.logHandle = logHandle
n.outHandle = outHandle
n.logThreshold = logThreshold
n.stdoutThreshold = outThreshold
if len(prefix) != 0 {
n.prefix = "[" + prefix + "] "
} else {
n.prefix = ""
}
n.flags = flags
n.LOG = log.New(n.logHandle,
"LOG: ",
n.flags)
n.FEEDBACK = &Feedback{n}
n.init()
return n
}
// Feedback is special. It writes plainly to the output while
// logging with the standard extra information (date, file, etc)
// Only Println and Printf are currently provided for this
type Feedback struct {
*Notepad
}
// init create the loggers for each level depending on the notepad thresholds
func (n *Notepad) init() {
bothHandle := io.MultiWriter(n.outHandle, n.logHandle)
for t, logger := range n.loggers {
threshold := Threshold(t)
counter := &logCounter{}
n.logCounters[t] = counter
switch {
case threshold >= n.logThreshold && threshold >= n.stdoutThreshold:
*logger = log.New(io.MultiWriter(counter, bothHandle), n.prefix+prefix(threshold), n.flags)
case threshold >= n.logThreshold:
*logger = log.New(io.MultiWriter(counter, n.logHandle), n.prefix+prefix(threshold), n.flags)
case threshold >= n.stdoutThreshold:
*logger = log.New(io.MultiWriter(counter, os.Stdout), n.prefix+prefix(threshold), n.flags)
default:
*logger = log.New(counter, n.prefix+prefix(threshold), n.flags)
}
}
}
// SetLogThreshold change the threshold above which messages are written to the
// log file
func (n *Notepad) SetLogThreshold(threshold Threshold) {
n.logThreshold = threshold
n.init()
}
// SetLogOutput change the file where log messages are written
func (n *Notepad) SetLogOutput(handle io.Writer) {
n.logHandle = handle
n.init()
}
// GetStdoutThreshold returns the defined Treshold for the log logger.
func (n *Notepad) GetLogThreshold() Threshold {
return n.logThreshold
}
// SetStdoutThreshold change the threshold above which messages are written to the
// standard output
func (n *Notepad) SetStdoutThreshold(threshold Threshold) {
n.stdoutThreshold = threshold
n.init()
}
// GetStdoutThreshold returns the Treshold for the stdout logger.
func (n *Notepad) GetStdoutThreshold() Threshold {
return n.stdoutThreshold
}
// SetPrefix change the prefix used by the notepad. Prefixes are displayed between
// brackets at the begining of the line. An empty prefix won't be displayed at all.
func (n *Notepad) SetPrefix(prefix string) {
if len(prefix) != 0 {
n.prefix = "[" + prefix + "] "
} else {
n.prefix = ""
}
n.init()
}
// SetFlags choose which flags the logger will display (after prefix and message
// level). See the package log for more informations on this.
func (n *Notepad) SetFlags(flags int) {
n.flags = flags
n.init()
}
// Feedback is special. It writes plainly to the output while
// logging with the standard extra information (date, file, etc)
// Only Println and Printf are currently provided for this
func (fb *Feedback) Println(v ...interface{}) {
s := fmt.Sprintln(v...)
fmt.Print(s)
fb.LOG.Output(2, s)
}
// Feedback is special. It writes plainly to the output while
// logging with the standard extra information (date, file, etc)
// Only Println and Printf are currently provided for this
func (fb *Feedback) Printf(format string, v ...interface{}) {
s := fmt.Sprintf(format, v...)
fmt.Print(s)
fb.LOG.Output(2, s)
}

View File

@ -0,0 +1,256 @@
// Copyright © 2016 Steve Francia <spf@spf13.com>.
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package jwalterweatherman
import (
"fmt"
"io"
"io/ioutil"
"log"
"os"
"sync/atomic"
)
// Level describes the chosen log level between
// debug and critical.
type Level int
type NotePad struct {
Handle io.Writer
Level Level
Prefix string
Logger **log.Logger
counter uint64
}
func (n *NotePad) incr() {
atomic.AddUint64(&n.counter, 1)
}
func (n *NotePad) resetCounter() {
atomic.StoreUint64(&n.counter, 0)
}
func (n *NotePad) getCount() uint64 {
return atomic.LoadUint64(&n.counter)
}
type countingWriter struct {
incrFunc func()
}
func (cw *countingWriter) Write(p []byte) (n int, err error) {
cw.incrFunc()
return 0, nil
}
// Feedback is special. It writes plainly to the output while
// logging with the standard extra information (date, file, etc)
// Only Println and Printf are currently provided for this
type Feedback struct{}
const (
LevelTrace Level = iota
LevelDebug
LevelInfo
LevelWarn
LevelError
LevelCritical
LevelFatal
DefaultLogThreshold = LevelWarn
DefaultStdoutThreshold = LevelError
)
var (
TRACE *log.Logger
DEBUG *log.Logger
INFO *log.Logger
WARN *log.Logger
ERROR *log.Logger
CRITICAL *log.Logger
FATAL *log.Logger
LOG *log.Logger
FEEDBACK Feedback
LogHandle io.Writer = ioutil.Discard
OutHandle io.Writer = os.Stdout
BothHandle io.Writer = io.MultiWriter(LogHandle, OutHandle)
NotePads []*NotePad = []*NotePad{trace, debug, info, warn, err, critical, fatal}
trace *NotePad = &NotePad{Level: LevelTrace, Handle: os.Stdout, Logger: &TRACE, Prefix: "TRACE: "}
debug *NotePad = &NotePad{Level: LevelDebug, Handle: os.Stdout, Logger: &DEBUG, Prefix: "DEBUG: "}
info *NotePad = &NotePad{Level: LevelInfo, Handle: os.Stdout, Logger: &INFO, Prefix: "INFO: "}
warn *NotePad = &NotePad{Level: LevelWarn, Handle: os.Stdout, Logger: &WARN, Prefix: "WARN: "}
err *NotePad = &NotePad{Level: LevelError, Handle: os.Stdout, Logger: &ERROR, Prefix: "ERROR: "}
critical *NotePad = &NotePad{Level: LevelCritical, Handle: os.Stdout, Logger: &CRITICAL, Prefix: "CRITICAL: "}
fatal *NotePad = &NotePad{Level: LevelFatal, Handle: os.Stdout, Logger: &FATAL, Prefix: "FATAL: "}
logThreshold Level = DefaultLogThreshold
outputThreshold Level = DefaultStdoutThreshold
)
const (
DATE = log.Ldate
TIME = log.Ltime
SFILE = log.Lshortfile
LFILE = log.Llongfile
MSEC = log.Lmicroseconds
)
var logFlags = DATE | TIME | SFILE
func init() {
SetStdoutThreshold(DefaultStdoutThreshold)
}
// initialize will setup the jWalterWeatherman standard approach of providing the user
// some feedback and logging a potentially different amount based on independent log and output thresholds.
// By default the output has a lower threshold than logged
// Don't use if you have manually set the Handles of the different levels as it will overwrite them.
func initialize() {
BothHandle = io.MultiWriter(LogHandle, OutHandle)
for _, n := range NotePads {
if n.Level < outputThreshold && n.Level < logThreshold {
n.Handle = ioutil.Discard
} else if n.Level >= outputThreshold && n.Level >= logThreshold {
n.Handle = BothHandle
} else if n.Level >= outputThreshold && n.Level < logThreshold {
n.Handle = OutHandle
} else {
n.Handle = LogHandle
}
}
for _, n := range NotePads {
n.Handle = io.MultiWriter(n.Handle, &countingWriter{n.incr})
*n.Logger = log.New(n.Handle, n.Prefix, logFlags)
}
LOG = log.New(LogHandle,
"LOG: ",
logFlags)
}
// Set the log Flags (Available flag: DATE, TIME, SFILE, LFILE and MSEC)
func SetLogFlag(flags int) {
logFlags = flags
initialize()
}
// Level returns the current global log threshold.
func LogThreshold() Level {
return logThreshold
}
// Level returns the current global output threshold.
func StdoutThreshold() Level {
return outputThreshold
}
// Ensures that the level provided is within the bounds of available levels
func levelCheck(level Level) Level {
switch {
case level <= LevelTrace:
return LevelTrace
case level >= LevelFatal:
return LevelFatal
default:
return level
}
}
// Establishes a threshold where anything matching or above will be logged
func SetLogThreshold(level Level) {
logThreshold = levelCheck(level)
initialize()
}
// Establishes a threshold where anything matching or above will be output
func SetStdoutThreshold(level Level) {
outputThreshold = levelCheck(level)
initialize()
}
// Conveniently Sets the Log Handle to a io.writer created for the file behind the given filepath
// Will only append to this file
func SetLogFile(path string) {
file, err := os.OpenFile(path, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0666)
if err != nil {
CRITICAL.Println("Failed to open log file:", path, err)
os.Exit(-1)
}
INFO.Println("Logging to", file.Name())
LogHandle = file
initialize()
}
// Conveniently Creates a temporary file and sets the Log Handle to a io.writer created for it
func UseTempLogFile(prefix string) {
file, err := ioutil.TempFile(os.TempDir(), prefix)
if err != nil {
CRITICAL.Println(err)
}
INFO.Println("Logging to", file.Name())
LogHandle = file
initialize()
}
// LogCountForLevel returns the number of log invocations for a given level.
func LogCountForLevel(l Level) uint64 {
for _, np := range NotePads {
if np.Level == l {
return np.getCount()
}
}
return 0
}
// LogCountForLevelsGreaterThanorEqualTo returns the number of log invocations
// greater than or equal to a given level threshold.
func LogCountForLevelsGreaterThanorEqualTo(threshold Level) uint64 {
var cnt uint64
for _, np := range NotePads {
if np.Level >= threshold {
cnt += np.getCount()
}
}
return cnt
}
// ResetLogCounters resets the invocation counters for all levels.
func ResetLogCounters() {
for _, np := range NotePads {
np.resetCounter()
}
}
// Disables logging for the entire JWW system
func DiscardLogging() {
LogHandle = ioutil.Discard
initialize()
}
// Feedback is special. It writes plainly to the output while
// logging with the standard extra information (date, file, etc)
// Only Println and Printf are currently provided for this
func (fb *Feedback) Println(v ...interface{}) {
s := fmt.Sprintln(v...)
fmt.Print(s)
LOG.Output(2, s)
}
// Feedback is special. It writes plainly to the output while
// logging with the standard extra information (date, file, etc)
// Only Println and Printf are currently provided for this
func (fb *Feedback) Printf(format string, v ...interface{}) {
s := fmt.Sprintf(format, v...)
fmt.Print(s)
LOG.Output(2, s)
}

View File

@ -1093,30 +1093,24 @@ func (v *Viper) ReadInConfig() error {
return err return err
} }
config := make(map[string]interface{}) v.config = make(map[string]interface{})
err = v.unmarshalReader(bytes.NewReader(file), config) return v.unmarshalReader(bytes.NewReader(file), v.config)
if err != nil {
return err
}
v.config = config
return nil
} }
// MergeInConfig merges a new configuration with an existing config. // MergeInConfig merges a new configuration with an existing config.
func MergeInConfig() error { return v.MergeInConfig() } func MergeInConfig() error { return v.MergeInConfig() }
func (v *Viper) MergeInConfig() error { func (v *Viper) MergeInConfig() error {
jww.INFO.Println("Attempting to merge in config file") jww.INFO.Println("Attempting to merge in config file")
if !stringInSlice(v.getConfigType(), SupportedExts) {
return UnsupportedConfigError(v.getConfigType())
}
filename, err := v.getConfigFile() filename, err := v.getConfigFile()
if err != nil { if err != nil {
return err return err
} }
if !stringInSlice(v.getConfigType(), SupportedExts) {
return UnsupportedConfigError(v.getConfigType())
}
file, err := afero.ReadFile(v.fs, filename) file, err := afero.ReadFile(v.fs, filename)
if err != nil { if err != nil {
return err return err

Some files were not shown because too many files have changed in this diff Show More