diff --git a/cmd/decrypt.go b/cmd/decrypt.go index f25485c..5bb7709 100644 --- a/cmd/decrypt.go +++ b/cmd/decrypt.go @@ -21,7 +21,7 @@ var decryptCmd = &cobra.Command{ }, } -//ExecuteDecrypt runs decrypt cmd +// ExecuteDecrypt runs decrypt cmd func ExecuteDecrypt() error { if dp.value == "" { bytes, err := ioutil.ReadAll(os.Stdin) diff --git a/cmd/decrypt_test.go b/cmd/decrypt_test.go index 0786cd0..96345aa 100644 --- a/cmd/decrypt_test.go +++ b/cmd/decrypt_test.go @@ -56,5 +56,5 @@ func ExampleExecuteDecrypt() { dp.source = ts.URL dp.value = tp.testContent ExecuteDecrypt() - //Output: test + // Output: test } diff --git a/cmd/diff.go b/cmd/diff.go index 3996873..4681fac 100644 --- a/cmd/diff.go +++ b/cmd/diff.go @@ -57,7 +57,7 @@ func validateDiffParams(cmd *cobra.Command, args []string) error { return nil } -//ExecuteDiffValues runs diff values cmd +// ExecuteDiffValues runs diff values cmd func ExecuteDiffValues() error { ext, err := client.ParseExtension(diffp.format) @@ -96,7 +96,7 @@ func ExecuteDiffValues() error { return difflib.WriteUnifiedDiff(os.Stdout, d) } -//ExecuteDiffFiles runs diff files cmd +// ExecuteDiffFiles runs diff files cmd func ExecuteDiffFiles() error { errorHandler := func(data []byte, err error) []byte { if e, ok := err.(client.HTTPError); ok && e.StatusCode() == http.StatusNotFound { diff --git a/cmd/encrypt.go b/cmd/encrypt.go index 28e37af..c106ddf 100644 --- a/cmd/encrypt.go +++ b/cmd/encrypt.go @@ -21,7 +21,7 @@ var encryptCmd = &cobra.Command{ }, } -//ExecuteEncrypt runs encrypt cmd +// ExecuteEncrypt runs encrypt cmd func ExecuteEncrypt() error { if ep.value == "" { bytes, err := ioutil.ReadAll(os.Stdin) diff --git a/cmd/encrypt_test.go b/cmd/encrypt_test.go index f1eb0a1..6d8f8fa 100644 --- a/cmd/encrypt_test.go +++ b/cmd/encrypt_test.go @@ -56,5 +56,5 @@ func ExampleExecuteEncrypt() { ep.source = ts.URL ep.value = tp.testContent ExecuteEncrypt() - //Output: test + // Output: test } diff --git a/cmd/filemapping.go b/cmd/filemapping.go index 9b11530..97dc670 100644 --- a/cmd/filemapping.go +++ b/cmd/filemapping.go @@ -8,13 +8,13 @@ import ( const mappingSeparator = "," const sourceDestSeparator = ":" -//FileMapping single file mapping source:dest +// FileMapping single file mapping source:dest type FileMapping struct { source string destination string } -//FileMappings file mappings source:dest,source:dest... +// FileMappings file mappings source:dest,source:dest... type FileMappings struct { mappings []FileMapping } @@ -23,7 +23,7 @@ func (m *FileMappings) String() string { return "" } -//Set parse mappings from string +// Set parse mappings from string func (m *FileMappings) Set(value string) error { mappings := strings.Split(value, mappingSeparator) @@ -41,17 +41,17 @@ func (m *FileMappings) Set(value string) error { return nil } -//Type type name (for cobra) +// Type type name (for cobra) func (m *FileMappings) Type() string { return "FileMappings" } -//Mappings all mappings +// Mappings all mappings func (m *FileMappings) Mappings() []FileMapping { return m.mappings } -//Sources all sources +// Sources all sources func (m *FileMappings) Sources() []string { sources := make([]string, len(m.mappings)) for i, mapping := range m.mappings { @@ -61,7 +61,7 @@ func (m *FileMappings) Sources() []string { return sources } -//Destinations all destinations +// Destinations all destinations func (m *FileMappings) Destinations() []string { destinations := make([]string, len(m.mappings)) for i, mapping := range m.mappings { diff --git a/cmd/get.go b/cmd/get.go index dd1c4ff..58b3649 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -42,7 +42,7 @@ var getFilesCmd = &cobra.Command{ }, } -//ExecuteGetValues runs get values cmd +// ExecuteGetValues runs get values cmd func ExecuteGetValues() error { ext, err := client.ParseExtension(gp.format) @@ -75,7 +75,7 @@ func ExecuteGetValues() error { return nil } -//ExecuteGetFiles runs get files cmd +// ExecuteGetFiles runs get files cmd func ExecuteGetFiles() error { for _, mapping := range gp.fileMappings.Mappings() { resp, err := client. diff --git a/cmd/root.go b/cmd/root.go index 107dc4b..bd8e7d2 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -38,7 +38,7 @@ func init() { rootCmd.AddCommand(versionCmd) } -//Execute run root command (main entrypoint) +// Execute run root command (main entrypoint) func Execute() error { return rootCmd.Execute() } diff --git a/go.mod b/go.mod index 58bc886..6c72a23 100644 --- a/go.mod +++ b/go.mod @@ -1,49 +1,26 @@ module github.com/WanderaOrg/scccmd require ( - github.com/PuerkitoBio/purell v1.1.0 // indirect - github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/cpuguy83/go-md2man v1.0.8 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect github.com/dimiro1/health v0.0.0-20170102175817-22672c488556 - github.com/emicklei/go-restful v2.6.0+incompatible // indirect - github.com/fsnotify/fsnotify v1.4.7 // indirect github.com/ghodss/yaml v1.0.0 - github.com/go-openapi/jsonpointer v0.0.0-20180322222829-3a0015ad55fa // indirect - github.com/go-openapi/jsonreference v0.0.0-20180322222742-3fb327e6747d // indirect - github.com/go-openapi/spec v0.0.0-20180326232708-9acd88844bc1 // indirect - github.com/go-openapi/swag v0.0.0-20180302192843-ceb469cb0fdf // indirect - github.com/gogo/protobuf v1.0.0 // indirect - github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect - github.com/golang/protobuf v1.2.0 // indirect - github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect + github.com/golang/protobuf v1.3.2 // indirect + github.com/google/go-cmp v0.3.1 // indirect github.com/howeyc/fsnotify v0.9.0 - github.com/hpcloud/tail v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect - github.com/json-iterator/go v0.0.0-20180315132816-ca39e5af3ece // indirect - github.com/mailru/easyjson v0.0.0-20180323154445-8b799c424f57 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v0.0.0-20180228065516-1df9eeb2bb81 // indirect - github.com/onsi/ginkgo v1.6.0 // indirect - github.com/onsi/gomega v1.3.0 + github.com/onsi/gomega v1.5.0 github.com/pmezard/go-difflib v1.0.0 github.com/russross/blackfriday v1.5.1 // indirect github.com/sirupsen/logrus v1.0.6 github.com/spf13/cobra v0.0.2 - github.com/spf13/pflag v1.0.0 // indirect - github.com/stretchr/testify v1.2.2 // indirect - golang.org/x/crypto v0.0.0-20180723164146-c126467f60eb // indirect - golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f // indirect - golang.org/x/sys v0.0.0-20180715085529-ac767d655b30 // indirect - golang.org/x/text v0.3.0 // indirect + golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect + golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 // indirect + golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a // indirect gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect - gopkg.in/fsnotify.v1 v1.4.7 // indirect gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect - gopkg.in/inf.v0 v0.9.0 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/resty.v1 v1.11.0 - gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect - gopkg.in/yaml.v2 v2.1.1 - k8s.io/api v0.0.0-20180103015100-006a217681ae - k8s.io/apimachinery v0.0.0-20180103014849-68f9c3a1feb3 - k8s.io/kube-openapi v0.0.0-20180216212618-50ae88d24ede // indirect + gopkg.in/yaml.v2 v2.2.2 + k8s.io/api v0.0.0-20190813220812-4c9d9526570f + k8s.io/apimachinery v0.0.0-20190813235223-d2c4b5819cd0 ) diff --git a/go.sum b/go.sum index 6e0e8f1..cbe316e 100644 --- a/go.sum +++ b/go.sum @@ -1,53 +1,81 @@ -github.com/PuerkitoBio/purell v1.1.0 h1:rmGxhojJlM0tuKtfdvliR84CFHljx9ag64t2xmVkjK4= -github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= -github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= +github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/cpuguy83/go-md2man v1.0.8 h1:DwoNytLphI8hzS2Af4D0dfaEaiSq2bN05mEm4R6vf8M= github.com/cpuguy83/go-md2man v1.0.8/go.mod h1:N6JayAiVKtlHSnuTCeuLSQVs75hb8q+dYQLjr7cDsKY= +github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dimiro1/health v0.0.0-20170102175817-22672c488556 h1:p1v4hqxlMEbORvXFGpzlPMbQzLUrhuHbAGtuBswD1ok= github.com/dimiro1/health v0.0.0-20170102175817-22672c488556/go.mod h1:2WfbHU/6ZesaUGq9D2HZACgyRIgmd4yg+ADNkXA0a74= -github.com/emicklei/go-restful v2.6.0+incompatible h1:luAX89wpjId5gV+GJV11MFD56GpAJTG2eUqCeDDgB98= -github.com/emicklei/go-restful v2.6.0+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= +github.com/elazarl/goproxy v0.0.0-20170405201442-c4fc26588b6e/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= +github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= +github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-openapi/jsonpointer v0.0.0-20180322222829-3a0015ad55fa h1:hr8WVDjg4JKtQptZpzyb196TmruCs7PIsdJz8KAOZp8= -github.com/go-openapi/jsonpointer v0.0.0-20180322222829-3a0015ad55fa/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= -github.com/go-openapi/jsonreference v0.0.0-20180322222742-3fb327e6747d h1:k3UQ7Z8yFYq0BNkYykKIheY0HlZBl1Hku+pO9HE9FNU= -github.com/go-openapi/jsonreference v0.0.0-20180322222742-3fb327e6747d/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= -github.com/go-openapi/spec v0.0.0-20180326232708-9acd88844bc1 h1:PYE2PdWmVwziWgcWq8QbIRIQzqhH7MACFxQV3Cie+54= -github.com/go-openapi/spec v0.0.0-20180326232708-9acd88844bc1/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= -github.com/go-openapi/swag v0.0.0-20180302192843-ceb469cb0fdf h1:+nKkqdRaDAb4G+VhUceeRkEaLQIxnoE8pZrKb3HCFtM= -github.com/go-openapi/swag v0.0.0-20180302192843-ceb469cb0fdf/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= -github.com/gogo/protobuf v1.0.0 h1:2jyBKDKU/8v3v2xVR2PtiWQviFUyiaGk2rpfyFT8rTM= -github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= +github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+35s3my2LFTysnkMfxsJBAMHj/DoqoB9knIWoYG/Vk0= +github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= +github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= +github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= +github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d h1:3PaI8p3seN09VjbTYC/QWlUZdZ1qS1zGjy7LH2Wt07I= +github.com/gogo/protobuf v1.2.2-0.20190723190241-65acae22fc9d/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/protobuf v0.0.0-20161109072736-4bd1920723d7/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck= -github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gnostic v0.0.0-20170426233943-68f4ded48ba9/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/howeyc/fsnotify v0.9.0 h1:0gtV5JmOKH4A8SsFxG2BczSeXWWPvcMT0euZt5gDAxY= github.com/howeyc/fsnotify v0.9.0/go.mod h1:41HzSPxBGeFRQKEEwgh49TRw/nKBsYZ2cF1OzPjSJsA= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/json-iterator/go v0.0.0-20180315132816-ca39e5af3ece h1:3HJXp/18JmMk5sjBP3LDUBtWjczCvynxaeAF6b6kWp8= -github.com/json-iterator/go v0.0.0-20180315132816-ca39e5af3ece/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/mailru/easyjson v0.0.0-20180323154445-8b799c424f57 h1:qhv1ir3dIyOFmFU+5KqG4dF3zSQTA4nn1DFhu2NQC44= -github.com/mailru/easyjson v0.0.0-20180323154445-8b799c424f57/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo= +github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180228065516-1df9eeb2bb81 h1:ImOHKpmdLPXWX5KSYquUWXKaopEPuY7TPPUo18u9aOI= -github.com/modern-go/reflect2 v0.0.0-20180228065516-1df9eeb2bb81/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v0.0.0-20180320133207-05fbef0ca5da/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= +github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v1.3.0 h1:yPHEatyQC4jN3vdfvqJXG7O9vfC6LhaAV1NEdYpP+h0= -github.com/onsi/gomega v1.3.0/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= +github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= +github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= +github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday v1.5.1 h1:B8ZN6pD4PVofmlDCDUdELeYrbsVIDM/bpjW3v3zgcRc= @@ -56,41 +84,73 @@ github.com/sirupsen/logrus v1.0.6 h1:hcP1GmhGigz/O7h1WVUM5KklBp1JoNS9FggWKdj/j3s github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjMPG0dEzc= github.com/spf13/cobra v0.0.2 h1:NfkwRbgViGoyjBKsLI0QMDcuMnhM+SBg3T0cGfpvKDE= github.com/spf13/cobra v0.0.2/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8= -github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/pflag v1.0.0 h1:oaPbdDe/x0UncahuwiPxW1GYJyilRAdsPnq3e1yaPcI= -github.com/spf13/pflag v1.0.0/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -golang.org/x/crypto v0.0.0-20180723164146-c126467f60eb h1:Ah9YqXLj6fEgeKqcmBuLCbAsrF3ScD7dJ/bYM0C6tXI= -golang.org/x/crypto v0.0.0-20180723164146-c126467f60eb/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc= +golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3 h1:eH6Eip3UpmR+yM/qI9Ijluzb1bNv/cAU/n+6l8tRSis= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 h1:fHDIZ2oxGnUZRN6WgWFCbYBjH9uqVPRCUVUDhs0wnbA= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180715085529-ac767d655b30 h1:4bYUqrXBoiI7UFQeibUwFhvcHfaEeL75O3lOcZa964o= -golang.org/x/sys v0.0.0-20180715085529-ac767d655b30/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a h1:aYOabOQFp6Vj6W1F80affTUvO9UxmJRx8K0gsfABByQ= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/airbrake/gobrake.v2 v2.0.9 h1:7z2uVWwn7oVeeugY1DtlPAy5H+KYgB1KeKTnqjNatLo= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 h1:OAj3g0cR6Dx/R07QgQe8wkA9RNjB2u4i700xBkIT4e0= gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= gopkg.in/inf.v0 v0.9.0 h1:3zYtXIO92bvsdS3ggAdA8Gb4Azj0YU+TVY1uGYNFA8o= gopkg.in/inf.v0 v0.9.0/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/resty.v1 v1.11.0 h1:z5nqGs/W/h91PLOc+WZefPj8rRZe8Ctlgxg/AtbJ+NE= gopkg.in/resty.v1 v1.11.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.1.1 h1:fxK3tv8mQPVEgxu/S2LJ040LyqiajHt+syP0CdDS/Sc= -gopkg.in/yaml.v2 v2.1.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -k8s.io/api v0.0.0-20180103015100-006a217681ae h1:fR7Ym1AktppiNEB8t8ba9ken3Bg0IXMLj11580T2mYg= -k8s.io/api v0.0.0-20180103015100-006a217681ae/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= -k8s.io/apimachinery v0.0.0-20180103014849-68f9c3a1feb3 h1:Nl/8rXdhJ0STzSBxQc1xMb4zs/zSTgCEPiFBslKzW+0= -k8s.io/apimachinery v0.0.0-20180103014849-68f9c3a1feb3/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0= -k8s.io/kube-openapi v0.0.0-20180216212618-50ae88d24ede h1:YOWlONzJUq456SnNYPcK/org5asA+LU6AzNBm+l/04o= -k8s.io/kube-openapi v0.0.0-20180216212618-50ae88d24ede/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +k8s.io/api v0.0.0-20190813220812-4c9d9526570f h1:GJd1WsysDrD6nTMnNi43CygTi4c3akjY6wDGlxaL2KE= +k8s.io/api v0.0.0-20190813220812-4c9d9526570f/go.mod h1:jQ/7CcVOYUjK7L7XC7+yxtZdjG6mm61Bmv9LU2K7M7c= +k8s.io/apimachinery v0.0.0-20190813220643-cbbcc3bf2cd4/go.mod h1:1Bb79pEWnDgUBI8vkD0vaOot2IDbQD8ONqOd66wgvlM= +k8s.io/apimachinery v0.0.0-20190813235223-d2c4b5819cd0 h1:s6iZdpAvDnCFrFsHSJY9Psb3yiOQ24CEsXdPznMpKcQ= +k8s.io/apimachinery v0.0.0-20190813235223-d2c4b5819cd0/go.mod h1:1Bb79pEWnDgUBI8vkD0vaOot2IDbQD8ONqOd66wgvlM= +k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= +k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk= +k8s.io/klog v0.4.0 h1:lCJCxf/LIowc2IGS9TPjWDyXY4nOmdGdfcwwDQCOURQ= +k8s.io/klog v0.4.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= +k8s.io/kube-openapi v0.0.0-20190709113604-33be087ad058/go.mod h1:nfDlWeOsu3pUf4yWGL+ERqohP4YsZcBJXWMK+gkzOA4= +sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= +sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= +sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/internal/testutil.go b/internal/testutil.go index ddbff56..a9fd041 100644 --- a/internal/testutil.go +++ b/internal/testutil.go @@ -5,7 +5,7 @@ import ( "testing" ) -//AssertString asserts string values and prints the expected and received values if failed +// AssertString asserts string values and prints the expected and received values if failed func AssertString(t *testing.T, message string, expected string, got string) { expected = trimString(expected) got = trimString(got) diff --git a/pkg/client/client.go b/pkg/client/client.go index b9e68bf..6556705 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -7,10 +7,10 @@ import ( "strings" ) -//Extension format of downloaded config +// Extension format of downloaded config type Extension string -//ParseExtension parse string into Extension type +// ParseExtension parse string into Extension type func ParseExtension(str string) (Extension, error) { switch value := strings.TrimRight(str, "\n"); value { case "json": @@ -40,38 +40,38 @@ const ( unknown Extension = "_" ) -//Client Spring Cloud Config Client +// Client Spring Cloud Config Client type Client interface { - //Config of the client + // Config of the client Config() *Config - //FetchFile queries the remote configuration service and returns the resulting file - //it is possible to pass error handler function as second parameter + // FetchFile queries the remote configuration service and returns the resulting file + // it is possible to pass error handler function as second parameter FetchFile(source string, errorHandler func([]byte, error) []byte) []byte - //FetchFileE queries the remote configuration service and returns the resulting file + // FetchFileE queries the remote configuration service and returns the resulting file FetchFileE(source string) ([]byte, error) - //FetchAs queries the remote configuration service and returns the result in specified format + // FetchAs queries the remote configuration service and returns the result in specified format FetchAs(extension Extension) (string, error) - //FetchAsJSON queries the remote configuration service and returns the result as a JSON string + // FetchAsJSON queries the remote configuration service and returns the result as a JSON string FetchAsJSON() (string, error) - //FetchAsYAML queries the remote configuration service and returns the result as a YAML string + // FetchAsYAML queries the remote configuration service and returns the result as a YAML string FetchAsYAML() (string, error) - //FetchAsProperties queries the remote configuration service and returns the result as a Properties string + // FetchAsProperties queries the remote configuration service and returns the result as a Properties string FetchAsProperties() (string, error) - //Encrypt encrypts the value server side and returns result + // Encrypt encrypts the value server side and returns result Encrypt(value string) (string, error) - //Decrypt decrypts the value server side and returns result + // Decrypt decrypts the value server side and returns result Decrypt(value string) (string, error) } -//Config needed to fetch a remote configuration +// Config needed to fetch a remote configuration type Config struct { URI string Profile string @@ -83,17 +83,17 @@ type client struct { config *Config } -//HTTPError used for wrapping an exception returned from Client +// HTTPError used for wrapping an exception returned from Client type HTTPError struct { *resty.Response } -//Error is an implementation of error type interface method +// Error is an implementation of error type interface method func (e HTTPError) Error() string { return fmt.Sprintf("unexpected response %d %v", e.StatusCode(), string(e.Body())) } -//NewClient creates instance of the Client +// NewClient creates instance of the Client func NewClient(c Config) Client { client := &client{ config: &c, @@ -113,19 +113,19 @@ func NewClient(c Config) Client { return client } -//Config of the client +// Config of the client func (c *client) Config() *Config { return c.config } -//FetchFileE queries the remote configuration service and returns the resulting file +// FetchFileE queries the remote configuration service and returns the resulting file func (c *client) FetchFileE(source string) ([]byte, error) { resp, err := resty.R().Get(c.formatFileURI(source)) return resp.Body(), err } -//FetchFile queries the remote configuration service and returns the resulting file +// FetchFile queries the remote configuration service and returns the resulting file func (c *client) FetchFile(source string, errorHandler func([]byte, error) []byte) []byte { resp, err := resty.R().Get(c.formatFileURI(source)) @@ -135,28 +135,28 @@ func (c *client) FetchFile(source string, errorHandler func([]byte, error) []byt return resp.Body() } -//FetchAsProperties queries the remote configuration service and returns the result as a Properties string +// FetchAsProperties queries the remote configuration service and returns the result as a Properties string func (c *client) FetchAsProperties() (string, error) { return c.FetchAs(properties) } -//FetchAsJSON queries the remote configuration service and returns the result as a JSON string +// FetchAsJSON queries the remote configuration service and returns the result as a JSON string func (c *client) FetchAsJSON() (string, error) { return c.FetchAs(json) } -//FetchAsYAML queries the remote configuration service and returns the result as a YAML string +// FetchAsYAML queries the remote configuration service and returns the result as a YAML string func (c *client) FetchAsYAML() (string, error) { return c.FetchAs(yaml) } -//FetchAs queries the remote configuration service and returns the result in specified format +// FetchAs queries the remote configuration service and returns the result in specified format func (c *client) FetchAs(extension Extension) (string, error) { resp, err := resty.R().Get(c.formatValuesURI(extension)) return resp.String(), err } -//Encrypt encrypts the value server side and returns result +// Encrypt encrypts the value server side and returns result func (c *client) Encrypt(value string) (string, error) { resp, err := resty.R(). SetHeader("Content-Type", "text/plain"). @@ -165,7 +165,7 @@ func (c *client) Encrypt(value string) (string, error) { return resp.String(), err } -//Decrypt decrypts the value server side and returns result +// Decrypt decrypts the value server side and returns result func (c *client) Decrypt(value string) (string, error) { resp, err := resty.R(). SetHeader("Content-Type", "text/plain"). diff --git a/pkg/inject/hook.go b/pkg/inject/hook.go index c03b567..824cd52 100644 --- a/pkg/inject/hook.go +++ b/pkg/inject/hook.go @@ -4,6 +4,7 @@ import ( "crypto/sha256" "crypto/tls" "encoding/json" + "errors" "fmt" "github.com/dimiro1/health" "github.com/howeyc/fsnotify" @@ -38,33 +39,33 @@ const ( // WebhookConfigDefaults configures default init container values. type WebhookConfigDefaults struct { - ContainerName string `json:"container-name"` - Label string `json:"label"` - Profile string `json:"profile"` - VolumeName string `json:"volume-name"` - VolumeMount string `json:"volume-mount"` - Source string `json:"source"` + ContainerName string `yaml:"container-name"` + Label string `yaml:"label"` + Profile string `yaml:"profile"` + VolumeName string `yaml:"volume-name"` + VolumeMount string `yaml:"volume-mount"` + Source string `yaml:"source"` } // InitContainerResourcesList resources for init container type InitContainerResourcesList struct { - CPU string `json:"cpu"` - Memory string `json:"memory"` + CPU string `yaml:"cpu"` + Memory string `yaml:"memory"` } // InitContainerResources resources for init container type InitContainerResources struct { - Requests InitContainerResourcesList `json:"requests"` - Limits InitContainerResourcesList `json:"limits"` + Requests InitContainerResourcesList `yaml:"requests"` + Limits InitContainerResourcesList `yaml:"limits"` } // WebhookConfig struct representing webhook configuration values. type WebhookConfig struct { - AnnotationPrefix string `json:"annotation-prefix"` - Policy InjectionPolicy `json:"policy"` - ContainerImage string `json:"container-image"` - Default WebhookConfigDefaults `json:"default"` - Resources InitContainerResources `json:"resources"` + AnnotationPrefix string `yaml:"annotation-prefix"` + Policy InjectionPolicy `yaml:"policy"` + ContainerImage string `yaml:"container-image"` + Default WebhookConfigDefaults `yaml:"default"` + Resources InitContainerResources `yaml:"resources"` } // Webhook implements a mutating webhook for automatic config injection. @@ -308,14 +309,23 @@ func (wh *Webhook) inject(ar *v1beta1.AdmissionReview) *v1beta1.AdmissionRespons injectKey := wh.config.AnnotationPrefix + "inject" req := ar.Request - var pod corev1.Pod - if err := json.Unmarshal(req.Object.Raw, &pod); err != nil { + if req == nil { + log.Error("Could not parse request body") + return toAdmissionResponse(errors.New("cannot parse admission request body")) + } + pod := corev1.Pod{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "v1", + Kind: "Pod", + }, + } + if _, _, err := deserializer.Decode(req.Object.Raw, nil, &pod); err != nil { log.Errorf("Could not unmarshal raw object: %v", err) return toAdmissionResponse(err) } - log.Infof("AdmissionReview for %s/%s/%s (%v) UID=%v Rfc6902PatchOperation=%v UserInfo=%v", - req.Kind, req.Namespace, req.Name, pod.Name, req.UID, req.Operation, req.UserInfo) + log.Infof("AdmissionReview for %s/%s/%s UID=%v Rfc6902PatchOperation=%v UserInfo=%v", + pod.Kind, pod.Namespace, pod.Name, req.UID, req.Operation, req.UserInfo) log.Debugf("Object: %v", string(req.Object.Raw)) log.Debugf("OldObject: %v", string(req.OldObject.Raw)) @@ -378,13 +388,4 @@ func toAdmissionResponse(err error) *v1beta1.AdmissionResponse { func init() { _ = corev1.AddToScheme(runtimeScheme) - //_ = admissionregistrationv1beta1.AddToScheme(runtimeScheme) - // - //// The `v1` package from k8s.io/kubernetes/pkgp/apis/core/v1 has - //// the object defaulting functions which are not included in - //// k8s.io/api/corev1. The default functions are required by - //// runtime.ObjectDefaulter to workaround lack of server-side - //// defaulting with webhooks (see - //// https://github.com/kubernetes/kubernetes/issues/57982). - //_ = v1.AddToScheme(runtimeScheme) } diff --git a/pkg/inject/hook_test.go b/pkg/inject/hook_test.go index 237b72d..5c20d08 100644 --- a/pkg/inject/hook_test.go +++ b/pkg/inject/hook_test.go @@ -187,8 +187,6 @@ func TestInjectRequired(t *testing.T) { } func makeTestData(t testing.TB, skip bool) []byte { - t.Helper() - pod := corev1.Pod{ ObjectMeta: metav1.ObjectMeta{ Name: "test", @@ -355,7 +353,7 @@ func TestRunAndServe(t *testing.T) { "name":"config-init", "image":"wanderadock/scccmd", "args":["get","values","--source","http://config-service.default.svc:8080","--application","c1","--profile","default","--label","master","--destination","config.yaml"], - "resources":{"limits":{"cpu":"50m","memory":"50M"},"requests":{"cpu":"10m","memory":"10M"}}, + "resources":{"limits":{"cpu":"100m","memory":"50M"},"requests":{"cpu":"100m","memory":"10M"}}, "volumeMounts":[{"name":"config-volume","mountPath":"/config"}] } },