From dc951cf71ef50383203deaf0bd5f9c008ddfde62 Mon Sep 17 00:00:00 2001 From: Jiri Sedlacek Date: Thu, 16 Aug 2018 15:46:54 +0200 Subject: [PATCH 1/3] Adding diff subcommand for scccmd --- cmd/diff.go | 158 ++++++++++++++++++++++++++++++++ cmd/diff_test.go | 210 +++++++++++++++++++++++++++++++++++++++++++ cmd/get.go | 4 +- cmd/get_test.go | 19 ++-- cmd/root.go | 3 +- pkg/client/client.go | 2 +- pkg/inject/hook.go | 2 +- 7 files changed, 386 insertions(+), 12 deletions(-) create mode 100644 cmd/diff.go create mode 100644 cmd/diff_test.go diff --git a/cmd/diff.go b/cmd/diff.go new file mode 100644 index 0000000..a89b0a2 --- /dev/null +++ b/cmd/diff.go @@ -0,0 +1,158 @@ +package cmd + +import ( + "errors" + "fmt" + "github.com/WanderaOrg/scccmd/pkg/client" + "github.com/pmezard/go-difflib/difflib" + log "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + "os" + "strings" +) + +var diffp = struct { + source string + application string + profile string + label string + format string + destination string + files string + targetProfile string + targetLabel string +}{} + +var diffCmd = &cobra.Command{ + Use: "diff", + Short: "Diff the config from the given config server", + PersistentPreRunE: validateDiffParams, +} + +var diffValuesCmd = &cobra.Command{ + Use: "values", + Short: "Diff the config values in specified format from the given config server", + RunE: func(cmd *cobra.Command, args []string) error { + return ExecuteDiffValues(args) + }, +} + +var diffFilesCmd = &cobra.Command{ + Use: "files", + Short: "Diff the config files from the given config server", + RunE: func(cmd *cobra.Command, args []string) error { + return ExecuteDiffFiles(args) + }, +} + +func validateDiffParams(cmd *cobra.Command, args []string) error { + err := rootCmd.PersistentPreRunE(cmd, args) + if err != nil { + return err + } + + if diffp.targetProfile == "" { + diffp.targetProfile = diffp.profile + } + if diffp.label == diffp.targetLabel { + return errors.New(fmt.Sprintf("--label=%s and --target-label=%s, values should not be the same", diffp.label, diffp.targetLabel)) + } + return nil +} + +//ExecuteDiffValues runs diff values cmd +func ExecuteDiffValues(args []string) error { + ext, err := client.ParseExtension(diffp.format) + + if err != nil { + return err + } + + respA, err := client. + NewClient(client.Config{URI: diffp.source, Profile: diffp.profile, Application: diffp.application, Label: diffp.label}). + FetchAs(ext) + + if err != nil { + return err + } + + log.Debugf("Config server response for label %s, profile %s:", diffp.label, diffp.profile) + log.Debug(string(respA)) + + respB, err := client. + NewClient(client.Config{URI: diffp.source, Profile: diffp.targetProfile, Application: diffp.application, Label: diffp.targetLabel}). + FetchAs(ext) + + if err != nil { + return err + } + + log.Debugf("Config server response for label %s, profile %s:", diffp.targetLabel, diffp.targetProfile) + log.Debug(string(respB)) + + d := difflib.UnifiedDiff{ + A: difflib.SplitLines(string(respA)), + B: difflib.SplitLines(string(respB)), + Context: 3, + } + + difflib.WriteUnifiedDiff(os.Stdout, d) + + return nil +} + +//ExecuteDiffFiles runs diff files cmd +func ExecuteDiffFiles(args []string) error { + for _, filename := range strings.Split(diffp.files, ",") { + respA, err := client. + NewClient(client.Config{URI: diffp.source, Profile: diffp.profile, Application: diffp.application, Label: diffp.label}). + FetchFile(filename) + + if err != nil { + return err + } + + log.Debug("Config server response for version A:") + log.Debug(string(respA)) + + respB, err := client. + NewClient(client.Config{URI: diffp.source, Profile: diffp.targetProfile, Application: diffp.application, Label: diffp.targetLabel}). + FetchFile(filename) + + if err != nil { + return err + } + + log.Debug("Config server response for version B:") + log.Debug(string(respB)) + + d := difflib.UnifiedDiff{ + A: difflib.SplitLines(string(respA)), + B: difflib.SplitLines(string(respB)), + Context: 3, + } + + difflib.WriteUnifiedDiff(os.Stdout, d) + } + log.Debug("Diff of files written to stdout") + return nil +} + +func init() { + diffCmd.AddCommand(diffFilesCmd) + diffCmd.AddCommand(diffValuesCmd) + diffCmd.PersistentFlags().StringVarP(&diffp.source, "source", "s", "", "address of the config server") + diffCmd.PersistentFlags().StringVarP(&diffp.application, "application", "a", "", "name of the application to get the config for") + diffCmd.PersistentFlags().StringVar(&diffp.profile, "profile", "default", "configuration profile") + diffCmd.PersistentFlags().StringVar(&diffp.label, "label", "master", "configuration label") + diffCmd.PersistentFlags().StringVar(&diffp.targetLabel, "target-label", "", "second label to diff with") + diffCmd.PersistentFlags().StringVar(&diffp.targetProfile, "target-profile", "", "second profile to diff with, --profile value will be used, if not defined") + diffCmd.MarkPersistentFlagRequired("source") + diffCmd.MarkPersistentFlagRequired("application") + diffCmd.MarkPersistentFlagRequired("target-label") + + diffFilesCmd.Flags().StringVarP(&diffp.files, "files", "f", "", "files to get in form of file1,file2, example '--files application.yaml,config.yaml'") + diffFilesCmd.MarkFlagRequired("files") + + diffValuesCmd.Flags().StringVarP(&diffp.format, "format", "f", "yaml", "output format might be one of 'json|yaml|properties'") +} diff --git a/cmd/diff_test.go b/cmd/diff_test.go new file mode 100644 index 0000000..1779411 --- /dev/null +++ b/cmd/diff_test.go @@ -0,0 +1,210 @@ +package cmd + +import ( + "fmt" + "io/ioutil" + "net/http" + "net/http/httptest" + "os" + "strings" + "testing" +) + +func TestExecuteDiffFiles(t *testing.T) { + var testParams = []struct { + appName string + fileName string + difftext string + testContentA string + profileA string + labelA string + requestURIA string + testContentB string + profileB string + labelB string + requestURIB string + }{ + {"app", + "src", + "@@ -1,3 +1,3 @@\n foo\n-bar\n+baz\n ", + "foo\nbar", + "default", + "master", + "/app/default/master/src", + "foo\nbaz", + "default", + "develop", + "/app/default/develop/src", + }, + {"app", + "src", + "@@ -1,3 +1,3 @@\n foo\n-bar\n+baz\n ", + "foo\nbar", + "development", + "master", + "/app/development/master/src", + "foo\nbaz", + "qa", + "master", + "/app/qa/master/src", + }, + {"app", + "src", + "", + "foo\nbar", + "default", + "master", + "/app/default/master/src", + "foo\nbar", + "default", + "develop", + "/app/default/develop/src", + }, + } + + for _, tp := range testParams { + func() { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.RequestURI == tp.requestURIA { + fmt.Fprintln(w, tp.testContentA) + } else if r.RequestURI == tp.requestURIB { + fmt.Fprintln(w, tp.testContentB) + } else { + t.Errorf("Expected call to '%s' or '%s', but got '%s' instead.", tp.requestURIA, tp.requestURIB, r.RequestURI) + } + })) + defer ts.Close() + + diffp.application = tp.appName + diffp.profile = tp.profileA + diffp.label = tp.labelA + diffp.targetLabel = tp.labelB + diffp.targetProfile = tp.profileB + diffp.source = ts.URL + diffp.files = tp.fileName + + filename := "stdout" + old := os.Stdout // keep backup of the real stdout + temp, _ := os.Create(filename) // create temp file + os.Stdout = temp + defer func() { + temp.Close() + os.Stdout = old // restoring the real stdout + }() + + if err := ExecuteDiffFiles(nil); err != nil { + t.Error("Execute failed with: ", err) + } + + raw, err := ioutil.ReadFile(filename) + defer os.Remove(filename) + if err != nil { + t.Error("Expected to download file: ", err) + } + + if response := strings.TrimRight(string(raw[:]), "\n"); response != tp.difftext { + t.Errorf("Expected response: '%s' got '%s' instead.", tp.difftext, response) + } + }() + } +} + +func TestExecuteDiffValues(t *testing.T) { + var testParams = []struct { + appName string + difftext string + testContentA string + profileA string + labelA string + requestURIA string + testContentB string + profileB string + labelB string + requestURIB string + format string + }{ + {"app", + "@@ -1,2 +1,2 @@\n foo: 1\n-bar: 2\n+baz: 2", + "foo: 1\nbar: 2", + "default", + "master", + "/master/app-default.yml", + "foo: 1\nbaz: 2", + "default", + "develop", + "/develop/app-default.yml", + "yaml", + }, + {"app", + "", + "foo=bar", + "default", + "master", + "/master/app-default.properties", + "foo=bar", + "default", + "develop", + "/develop/app-default.properties", + "properties", + }, + {"app", + "@@ -1 +1 @@\n-{\"foo\":\"bar\", \"foo\":\"bar\"}\n+{\"foo\":\"bar\", \"foo\":\"baz\"}", + "{\"foo\":\"bar\", \"foo\":\"bar\"}", + "qa", + "master", + "/master/app-qa.json", + "{\"foo\":\"bar\", \"foo\":\"baz\"}", + "development", + "develop", + "/develop/app-development.json", + "json", + }, + } + + for _, tp := range testParams { + func() { + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.RequestURI == tp.requestURIA { + fmt.Fprintln(w, tp.testContentA) + } else if r.RequestURI == tp.requestURIB { + fmt.Fprintln(w, tp.testContentB) + } else { + t.Errorf("Expected call to '%s' or '%s', but got '%s' instead.", tp.requestURIA, tp.requestURIB, r.RequestURI) + } + })) + defer ts.Close() + + diffp.application = tp.appName + diffp.profile = tp.profileA + diffp.label = tp.labelA + diffp.targetProfile = tp.profileB + diffp.targetLabel = tp.labelB + diffp.source = ts.URL + diffp.format = tp.format + + filename := "stdout" + old := os.Stdout // keep backup of the real stdout + temp, _ := os.Create(filename) // create temp file + os.Stdout = temp + defer func() { + temp.Close() + os.Stdout = old // restoring the real stdout + }() + + if err := ExecuteDiffValues(nil); err != nil { + t.Error("Execute failed with: ", err) + } + + raw, err := ioutil.ReadFile(filename) + defer os.Remove(filename) + if err != nil { + t.Error("Expected to download file: ", err) + } + + if response := strings.TrimRight(string(raw[:]), "\n"); response != tp.difftext { + t.Errorf("Expected response: '%s' got '%s' instead.", tp.difftext, response) + } + }() + } + +} diff --git a/cmd/get.go b/cmd/get.go index b7b31c0..4a0d933 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -111,8 +111,8 @@ func init() { getCmd.PersistentFlags().StringVarP(&gp.application, "application", "a", "", "name of the application to get the config for") getCmd.PersistentFlags().StringVarP(&gp.profile, "profile", "p", "default", "configuration profile") getCmd.PersistentFlags().StringVarP(&gp.label, "label", "l", "master", "configuration label") - getCmd.MarkFlagRequired("source") - getCmd.MarkFlagRequired("application") + getCmd.MarkPersistentFlagRequired("source") + getCmd.MarkPersistentFlagRequired("application") getFilesCmd.Flags().VarP(&gp.fileMappings, "files", "f", "files to get in form of source:destination pairs, you can use - as a output to stdout, example '--files application.yaml:config.yaml'") getFilesCmd.MarkFlagRequired("files") diff --git a/cmd/get_test.go b/cmd/get_test.go index 7d21ed6..d023c06 100644 --- a/cmd/get_test.go +++ b/cmd/get_test.go @@ -10,8 +10,8 @@ import ( "testing" ) -func TestNoArgExecute(t *testing.T) { - err := ExecuteGetFiles(nil) +func TestNoArgGetExecute(t *testing.T) { + err := ExecuteDiffFiles(nil) if err != nil { t.Error("Execute failed with: ", err) } @@ -115,25 +115,29 @@ func TestExecuteGetValues(t *testing.T) { label string destFileName string requestURI string + format string }{ {"{\"foo\":\"bar\"}", "app", "default", "master", "dest", - "/master/app-default.yml"}, - {"{\"bar\":\"foo\"}", + "/master/app-default.json", + "json"}, + {"bar=foo", "app2", "default", "master", "destination", - "/master/app2-default.yml"}, - {"{\"foo\":\"bar\"}", + "/master/app2-default.properties", + "properties"}, + {"\"foo\":\"bar\"", "app", "prod", "1.0.0", "config.yaml", - "/1.0.0/app-prod.yml"}, + "/1.0.0/app-prod.yml", + "yaml"}, } for _, tp := range testParams { @@ -152,6 +156,7 @@ func TestExecuteGetValues(t *testing.T) { gp.label = tp.label gp.source = ts.URL gp.destination = tp.destFileName + gp.format = tp.format if err := ExecuteGetValues(nil); err != nil { t.Error("Execute failed with: ", err) diff --git a/cmd/root.go b/cmd/root.go index 589e87d..0341b0d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -13,7 +13,7 @@ var rootCmd = &cobra.Command{ DisableAutoGenTag: true, Short: "Spring Cloud Config management tool", Long: `Commandline tool used for managing configuration from Spring Cloud Config Server. -Tool currently provides functionality t get (download) config file from server.`, +Tool currently provides functionality to get (download) config file from server.`, PersistentPreRunE: func(cmd *cobra.Command, args []string) error { lvl, err := log.ParseLevel(loglevel) if err != nil { @@ -33,6 +33,7 @@ func init() { rootCmd.AddCommand(encryptCmd) rootCmd.AddCommand(decryptCmd) rootCmd.AddCommand(webhookCmd) + rootCmd.AddCommand(diffCmd) } //Execute run root command (main entrypoint) diff --git a/pkg/client/client.go b/pkg/client/client.go index 2992ce9..744198b 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -11,7 +11,7 @@ type Extension string //ParseExtension parse string into Extension type func ParseExtension(str string) (Extension, error) { - switch value := strings.TrimRight(str, "/n"); value { + switch value := strings.TrimRight(str, "\n"); value { case "json": return json, nil case "properties": diff --git a/pkg/inject/hook.go b/pkg/inject/hook.go index e26100c..cde84f0 100644 --- a/pkg/inject/hook.go +++ b/pkg/inject/hook.go @@ -367,7 +367,7 @@ func loadConfig(injectFile string) (*WebhookConfig, error) { return nil, err } - log.Infof("New configuration: sha256sum %x", sha256.Sum256(data)) + log.Debugf("Configuration loaded: sha256sum %x", sha256.Sum256(data)) return &c, nil } From 47bdfa59e843bdd2c636d639497ddbbe84d26e14 Mon Sep 17 00:00:00 2001 From: Jiri Sedlacek Date: Thu, 16 Aug 2018 15:47:33 +0200 Subject: [PATCH 2/3] Updating Gopkg lock --- Gopkg.lock | 115 ++++++++++++++++++++++++++++++++++++++++++++++++----- Gopkg.toml | 4 ++ 2 files changed, 108 insertions(+), 11 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index a3470e9..949183c 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -2,136 +2,177 @@ [[projects]] + digest = "1:d1665c44bd5db19aaee18d1b6233c99b0b9a986e8bccb24ef54747547a48027f" name = "github.com/PuerkitoBio/purell" packages = ["."] + pruneopts = "UT" revision = "0bcb03f4b4d0a9428594752bd2a3b9aa0a9d4bd4" version = "v1.1.0" [[projects]] branch = "master" + digest = "1:c739832d67eb1e9cc478a19cc1a1ccd78df0397bf8a32978b759152e205f644b" name = "github.com/PuerkitoBio/urlesc" packages = ["."] + pruneopts = "UT" revision = "de5bf2ad457846296e2031421a34e2568e304e35" [[projects]] + digest = "1:7cb4fdca4c251b3ef8027c90ea35f70c7b661a593b9eeae34753c65499098bb1" name = "github.com/cpuguy83/go-md2man" packages = ["md2man"] + pruneopts = "UT" revision = "20f5889cbdc3c73dbd2862796665e7c465ade7d1" version = "v1.0.8" [[projects]] branch = "master" + digest = "1:0c8cec131865737f9c594a1c1e1f9e85cd5d8c1d152ba0d6323b452506dfe722" name = "github.com/dimiro1/health" packages = ["."] + pruneopts = "UT" revision = "22672c48855646f5d54b6315336d2e3fee6eef81" [[projects]] + digest = "1:d91a89491d49259e41fb09c3a3d42f740d84edee064d8ecede0d64b388bfad71" name = "github.com/emicklei/go-restful" packages = [ ".", - "log" + "log", ] + pruneopts = "UT" revision = "26b41036311f2da8242db402557a0dbd09dc83da" version = "v2.6.0" [[projects]] + digest = "1:2cd7915ab26ede7d95b8749e6b1f933f1c6d5398030684e6505940a10f31cfda" name = "github.com/ghodss/yaml" packages = ["."] + pruneopts = "UT" revision = "0ca9ea5df5451ffdf184b4428c902747c2c11cd7" version = "v1.0.0" [[projects]] branch = "master" + digest = "1:2997679181d901ac8aaf4330d11138ecf3974c6d3334995ff36f20cbd597daf8" name = "github.com/go-openapi/jsonpointer" packages = ["."] + pruneopts = "UT" revision = "3a0015ad55fa9873f41605d3e8f28cd279c32ab2" [[projects]] branch = "master" + digest = "1:1ae3f233d75a731b164ca9feafd8ed646cbedf1784095876ed6988ce8aa88b1f" name = "github.com/go-openapi/jsonreference" packages = ["."] + pruneopts = "UT" revision = "3fb327e6747da3043567ee86abd02bb6376b6be2" [[projects]] branch = "master" + digest = "1:a1e96e25bf3b36e86479f86deda110f412195819f81e2d3ec617238a9fbc991d" name = "github.com/go-openapi/spec" packages = ["."] + pruneopts = "UT" revision = "9acd88844bc186c3ec7f318cd3d56f1114b4ab99" [[projects]] branch = "master" + digest = "1:b324ae8d3f2d03697fce51dd4f1db6ca81cfd774fbc030998c3409d02f371f89" name = "github.com/go-openapi/swag" packages = ["."] + pruneopts = "UT" revision = "ceb469cb0fdf2d792f28d771bc05da6c606f55e5" [[projects]] + digest = "1:e9559050c59ca91f1c4c7cf864b2b75367754543588fe595fac52dc84f19778e" name = "github.com/go-resty/resty" packages = ["."] + pruneopts = "UT" revision = "65798e030a35b911602b4d1d743d6f50ac93b665" version = "v1.3" [[projects]] + digest = "1:a7534feda0f15b5fd691e59e4fb6b7547e27df4b415a62e02c7cb71b3439c1b1" name = "github.com/gogo/protobuf" packages = [ "proto", - "sortkeys" + "sortkeys", ] + pruneopts = "UT" revision = "1adfc126b41513cc696b209667c8656ea7aac67c" version = "v1.0.0" [[projects]] branch = "master" + digest = "1:1ba1d79f2810270045c328ae5d674321db34e3aae468eb4233883b473c5c0467" name = "github.com/golang/glog" packages = ["."] + pruneopts = "UT" revision = "23def4e6c14b4da8ac2ed8007337bc5eb5007998" [[projects]] branch = "master" + digest = "1:3ee90c0d94da31b442dde97c99635aaafec68d0b8a3c12ee2075c6bdabeec6bb" name = "github.com/google/gofuzz" packages = ["."] + pruneopts = "UT" revision = "24818f796faf91cd76ec7bddd72458fbced7a6c1" [[projects]] + digest = "1:7159b4af2aae0c37b088cea9cb5932b8801a289616c5b789e4669558521cff0c" name = "github.com/howeyc/fsnotify" packages = ["."] + pruneopts = "UT" revision = "441bbc86b167f3c1f4786afae9931403b99fdacf" version = "v0.9.0" [[projects]] + digest = "1:870d441fe217b8e689d7949fef6e43efbc787e50f200cb1e70dbca9204a1d6be" name = "github.com/inconshreveable/mousetrap" packages = ["."] + pruneopts = "UT" revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75" version = "v1.0" [[projects]] + digest = "1:b1d4df033414c1a0d85fa7037b9aaf03746314811c860a95ea2d5fd481cd6c35" name = "github.com/json-iterator/go" packages = ["."] + pruneopts = "UT" revision = "ca39e5af3ece67bbcda3d0f4f56a8e24d9f2dad4" version = "1.1.3" [[projects]] branch = "master" + digest = "1:ada518b8c338e10e0afa443d84671476d3bd1d926e13713938088e8ddbee1a3e" name = "github.com/mailru/easyjson" packages = [ "buffer", "jlexer", - "jwriter" + "jwriter", ] + pruneopts = "UT" revision = "8b799c424f57fa123fc63a99d6383bc6e4c02578" [[projects]] + digest = "1:33422d238f147d247752996a26574ac48dcf472976eda7f5134015f06bf16563" name = "github.com/modern-go/concurrent" packages = ["."] + pruneopts = "UT" revision = "bacd9c7ef1dd9b15be4a9909b8ac7a4e313eec94" version = "1.0.3" [[projects]] + digest = "1:d711dfcf661439f1ef0b202a02e8a1ff4deac48f26f34253520dcdbecbd7c5f1" name = "github.com/modern-go/reflect2" packages = ["."] + pruneopts = "UT" revision = "1df9eeb2bb81f327b96228865c5687bc2194af3f" version = "1.0.0" [[projects]] + digest = "1:038734db8a70cdd73d4215081b22236e2aed3e65ca0727f6afd0ed839630e738" name = "github.com/onsi/gomega" packages = [ ".", @@ -145,46 +186,66 @@ "matchers/support/goraph/edge", "matchers/support/goraph/node", "matchers/support/goraph/util", - "types" + "types", ] + pruneopts = "UT" revision = "003f63b7f4cff3fc95357005358af2de0f5fe152" version = "v1.3.0" [[projects]] + digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe" + name = "github.com/pmezard/go-difflib" + packages = ["difflib"] + pruneopts = "UT" + revision = "792786c7400a136282c1664665ae0a8db921c6c2" + version = "v1.0.0" + +[[projects]] + digest = "1:8bc629776d035c003c7814d4369521afe67fdb8efc4b5f66540d29343b98cf23" name = "github.com/russross/blackfriday" packages = ["."] + pruneopts = "UT" revision = "55d61fa8aa702f59229e6cff85793c22e580eaf5" version = "v1.5.1" [[projects]] + digest = "1:d867dfa6751c8d7a435821ad3b736310c2ed68945d05b50fb9d23aee0540c8cc" name = "github.com/sirupsen/logrus" packages = ["."] + pruneopts = "UT" revision = "3e01752db0189b9157070a0e1668a620f9a85da2" version = "v1.0.6" [[projects]] + digest = "1:f56a38901e3d06fb5c71219d4e5b48d546d845f776d6219097733ec27011dc60" name = "github.com/spf13/cobra" packages = [ ".", - "doc" + "doc", ] + pruneopts = "UT" revision = "a1f051bc3eba734da4772d60e2d677f47cf93ef4" version = "v0.0.2" [[projects]] + digest = "1:1b21a2b4058a779f290c7341cd93267492e0ecea6c8b54f64a4a5fd7ff131034" name = "github.com/spf13/pflag" packages = ["."] + pruneopts = "UT" revision = "e57e3eeb33f795204c1ca35f56c44f83227c6e66" version = "v1.0.0" [[projects]] branch = "master" + digest = "1:3f3a05ae0b95893d90b9b3b5afdb79a9b3d96e4e36e099d841ae602e4aca0da8" name = "golang.org/x/crypto" packages = ["ssh/terminal"] + pruneopts = "UT" revision = "c126467f60eb25f8f27e5a981f32a87e3965053f" [[projects]] branch = "master" + digest = "1:1b231f9ce135c7f459bd3fe9ba672d363d07ff1ca75eaa00186932ea344ef2e4" name = "golang.org/x/net" packages = [ "html", @@ -194,20 +255,24 @@ "http2/hpack", "idna", "lex/httplex", - "publicsuffix" + "publicsuffix", ] + pruneopts = "UT" revision = "07e8617a6db2368fa55d4616f371ee1b1403c817" [[projects]] branch = "master" + digest = "1:3364d01296ce7eeca363e3d530ae63a2092d6f8efb85fb3d101e8f6d7de83452" name = "golang.org/x/sys" packages = [ "unix", - "windows" + "windows", ] + pruneopts = "UT" revision = "ac767d655b305d4e9612f5f6e33120b9176c4ad4" [[projects]] + digest = "1:bb8277a2ca2bcad6ff7f413b939375924099be908cedd1314baa21ecd08df477" name = "golang.org/x/text" packages = [ "collate", @@ -236,34 +301,42 @@ "unicode/cldr", "unicode/norm", "unicode/rangetable", - "width" + "width", ] + pruneopts = "UT" revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0" version = "v0.3.0" [[projects]] + digest = "1:ef72505cf098abdd34efeea032103377bec06abb61d8a06f002d5d296a4b1185" name = "gopkg.in/inf.v0" packages = ["."] + pruneopts = "UT" revision = "3887ee99ecf07df5b447e9b00d9c0b2adaa9f3e4" version = "v0.9.0" [[projects]] + digest = "1:2a81c6e126d36ad027328cffaa4888fc3be40f09dc48028d1f93705b718130b9" name = "gopkg.in/yaml.v2" packages = ["."] + pruneopts = "UT" revision = "7f97868eec74b32b0982dd158a51a446d1da7eb5" version = "v2.1.1" [[projects]] + digest = "1:2f97e58bdbf1f98f44c0166449e37b6f6a45d546daceb25350c3825936be31d9" name = "k8s.io/api" packages = [ "admission/v1beta1", "authentication/v1", - "core/v1" + "core/v1", ] + pruneopts = "UT" revision = "006a217681ae70cbacdd66a5e2fca1a61a8ff28e" version = "kubernetes-1.9.1" [[projects]] + digest = "1:f0fdc5a7b4ea116606d559da5d711b5853a76e78bfc8eab16db49ecf65d57b93" name = "k8s.io/apimachinery" packages = [ "pkg/api/resource", @@ -293,20 +366,40 @@ "pkg/util/wait", "pkg/util/yaml", "pkg/watch", - "third_party/forked/golang/reflect" + "third_party/forked/golang/reflect", ] + pruneopts = "UT" revision = "68f9c3a1feb3140df59c67ced62d3a5df8e6c9c2" version = "kubernetes-1.9.1" [[projects]] branch = "master" + digest = "1:f5487c07872bdb7c40ffe629430b2fa815f9eca0d2c02bb9e866962eb38a0e70" name = "k8s.io/kube-openapi" packages = ["pkg/common"] + pruneopts = "UT" revision = "50ae88d24ede7b8bad68e23c805b5d3da5c8abaf" [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "08a5700d37665e2e317b4d2b95a2cebbfd07b14e94e36702e167b7f00c29148b" + input-imports = [ + "github.com/dimiro1/health", + "github.com/ghodss/yaml", + "github.com/go-resty/resty", + "github.com/howeyc/fsnotify", + "github.com/onsi/gomega", + "github.com/pmezard/go-difflib/difflib", + "github.com/sirupsen/logrus", + "github.com/spf13/cobra", + "github.com/spf13/cobra/doc", + "gopkg.in/yaml.v2", + "k8s.io/api/admission/v1beta1", + "k8s.io/api/core/v1", + "k8s.io/apimachinery/pkg/api/resource", + "k8s.io/apimachinery/pkg/apis/meta/v1", + "k8s.io/apimachinery/pkg/runtime", + "k8s.io/apimachinery/pkg/runtime/serializer", + ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 02c6038..f0e5d34 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -33,3 +33,7 @@ [[constraint]] name = "github.com/howeyc/fsnotify" version = "0.9.0" + +[[constraint]] + name = "github.com/pmezard/go-difflib" + version = "1.0.0" From 9a31b3e1d1fa4347dcb59bbf1d7cfc045d31b05b Mon Sep 17 00:00:00 2001 From: Jiri Sedlacek Date: Thu, 16 Aug 2018 15:47:53 +0200 Subject: [PATCH 3/3] Updating documentation for scccmd diff commands --- docs/scccmd.md | 3 ++- docs/scccmd_diff.md | 32 ++++++++++++++++++++++++++++++++ docs/scccmd_diff_files.md | 35 +++++++++++++++++++++++++++++++++++ docs/scccmd_diff_values.md | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 docs/scccmd_diff.md create mode 100644 docs/scccmd_diff_files.md create mode 100644 docs/scccmd_diff_values.md diff --git a/docs/scccmd.md b/docs/scccmd.md index 5de32fe..cf9f108 100644 --- a/docs/scccmd.md +++ b/docs/scccmd.md @@ -5,7 +5,7 @@ Spring Cloud Config management tool ### Synopsis Commandline tool used for managing configuration from Spring Cloud Config Server. -Tool currently provides functionality t get (download) config file from server. +Tool currently provides functionality to get (download) config file from server. ### Options @@ -17,6 +17,7 @@ Tool currently provides functionality t get (download) config file from server. ### SEE ALSO * [scccmd decrypt](scccmd_decrypt.md) - Decrypt the value server-side and prints the response +* [scccmd diff](scccmd_diff.md) - Diff the config from the given config server * [scccmd encrypt](scccmd_encrypt.md) - Encrypt the value server-side and prints the response * [scccmd gendoc](scccmd_gendoc.md) - Generates documentation for this tool in Markdown format * [scccmd get](scccmd_get.md) - Get the config from the given config server diff --git a/docs/scccmd_diff.md b/docs/scccmd_diff.md new file mode 100644 index 0000000..de2f088 --- /dev/null +++ b/docs/scccmd_diff.md @@ -0,0 +1,32 @@ +## scccmd diff + +Diff the config from the given config server + +### Synopsis + +Diff the config from the given config server + +### Options + +``` + -a, --application string name of the application to get the config for + -h, --help help for diff + --label string configuration label (default "master") + --profile string configuration profile (default "default") + -s, --source string address of the config server + --target-label string second label to diff with + --target-profile string second profile to diff with, --profile value will be used, if not defined +``` + +### Options inherited from parent commands + +``` + --log-level string command log level (options: [panic fatal error warning info debug]) (default "info") +``` + +### SEE ALSO + +* [scccmd](scccmd.md) - Spring Cloud Config management tool +* [scccmd diff files](scccmd_diff_files.md) - Diff the config files from the given config server +* [scccmd diff values](scccmd_diff_values.md) - Diff the config values in specified format from the given config server + diff --git a/docs/scccmd_diff_files.md b/docs/scccmd_diff_files.md new file mode 100644 index 0000000..4f1572e --- /dev/null +++ b/docs/scccmd_diff_files.md @@ -0,0 +1,35 @@ +## scccmd diff files + +Diff the config files from the given config server + +### Synopsis + +Diff the config files from the given config server + +``` +scccmd diff files [flags] +``` + +### Options + +``` + -f, --files string files to get in form of file1,file2, example '--files application.yaml,config.yaml' + -h, --help help for files +``` + +### Options inherited from parent commands + +``` + -a, --application string name of the application to get the config for + --label string configuration label (default "master") + --log-level string command log level (options: [panic fatal error warning info debug]) (default "info") + --profile string configuration profile (default "default") + -s, --source string address of the config server + --target-label string second label to diff with + --target-profile string second profile to diff with, --profile value will be used, if not defined +``` + +### SEE ALSO + +* [scccmd diff](scccmd_diff.md) - Diff the config from the given config server + diff --git a/docs/scccmd_diff_values.md b/docs/scccmd_diff_values.md new file mode 100644 index 0000000..e6030d2 --- /dev/null +++ b/docs/scccmd_diff_values.md @@ -0,0 +1,35 @@ +## scccmd diff values + +Diff the config values in specified format from the given config server + +### Synopsis + +Diff the config values in specified format from the given config server + +``` +scccmd diff values [flags] +``` + +### Options + +``` + -f, --format string output format might be one of 'json|yaml|properties' (default "yaml") + -h, --help help for values +``` + +### Options inherited from parent commands + +``` + -a, --application string name of the application to get the config for + --label string configuration label (default "master") + --log-level string command log level (options: [panic fatal error warning info debug]) (default "info") + --profile string configuration profile (default "default") + -s, --source string address of the config server + --target-label string second label to diff with + --target-profile string second profile to diff with, --profile value will be used, if not defined +``` + +### SEE ALSO + +* [scccmd diff](scccmd_diff.md) - Diff the config from the given config server +