From 49507efe77c88aa0acd502a3f3e85ef841e05f3e Mon Sep 17 00:00:00 2001 From: Jakub Dyszkiewicz Date: Thu, 19 Sep 2019 19:30:29 +0200 Subject: [PATCH] feat(kumactl) postgres review fix --- .../cmd/install/install_database_schema.go | 2 +- .../install/install_database_schema_test.go | 6 ++--- ..._schema.sql => postgres_schema.golden.sql} | 0 docs/cmd/kumactl/HELP.md | 22 ++++++++++--------- install/postgres/README.md | 4 ++-- tools/docs/kumactl/gen_help.sh | 2 +- tools/postgres/docker-compose.yaml | 2 +- 7 files changed, 20 insertions(+), 18 deletions(-) rename app/kumactl/cmd/install/testdata/{postgres_schema.sql => postgres_schema.golden.sql} (100%) diff --git a/app/kumactl/cmd/install/install_database_schema.go b/app/kumactl/cmd/install/install_database_schema.go index f984730f793d..6fda51d60fbe 100644 --- a/app/kumactl/cmd/install/install_database_schema.go +++ b/app/kumactl/cmd/install/install_database_schema.go @@ -14,7 +14,7 @@ func newInstallDatabaseSchemaCmd() *cobra.Command { }{} cmd := &cobra.Command{ Use: "database-schema", - Short: "Install Kuma schema on DB.", + Short: "Install Kuma schema on DB", Long: `Install Kuma schema on DB.`, Example: `1. kumactl install database-schema --target=postgres | PGPASSWORD=mysecretpassword psql -h localhost -U postgres 2. sql_file=$(mktemp) ; \ diff --git a/app/kumactl/cmd/install/install_database_schema_test.go b/app/kumactl/cmd/install/install_database_schema_test.go index 70f109387199..8842d1245444 100644 --- a/app/kumactl/cmd/install/install_database_schema_test.go +++ b/app/kumactl/cmd/install/install_database_schema_test.go @@ -9,7 +9,7 @@ import ( "path/filepath" ) -var _ = Describe("kumactl install postgres-schema", func() { +var _ = Describe("kumactl install database-schema", func() { It("should give the schema postgres", func() { // given stdout := bytes.Buffer{} @@ -17,7 +17,7 @@ var _ = Describe("kumactl install postgres-schema", func() { rootCmd.SetOut(&stdout) rootCmd.SetArgs([]string{"install", "database-schema", "--target=postgres"}) - bytes, err := ioutil.ReadFile(filepath.Join("testdata", "postgres_schema.sql")) + expected, err := ioutil.ReadFile(filepath.Join("testdata", "postgres_schema.golden.sql")) Expect(err).ToNot(HaveOccurred()) // when @@ -25,6 +25,6 @@ var _ = Describe("kumactl install postgres-schema", func() { // then Expect(err).ToNot(HaveOccurred()) - Expect(string(stdout.Bytes())).To(Equal(string(bytes))) + Expect(string(stdout.Bytes())).To(Equal(string(expected))) }) }) diff --git a/app/kumactl/cmd/install/testdata/postgres_schema.sql b/app/kumactl/cmd/install/testdata/postgres_schema.golden.sql similarity index 100% rename from app/kumactl/cmd/install/testdata/postgres_schema.sql rename to app/kumactl/cmd/install/testdata/postgres_schema.golden.sql diff --git a/docs/cmd/kumactl/HELP.md b/docs/cmd/kumactl/HELP.md index 2dc0c89f0666..8683b10515e2 100644 --- a/docs/cmd/kumactl/HELP.md +++ b/docs/cmd/kumactl/HELP.md @@ -190,7 +190,7 @@ Usage: Available Commands: control-plane Install Kuma Control Plane on Kubernetes - database-schema Install Kuma schema on DB. + database-schema Install Kuma schema on DB Flags: -h, --help help for install @@ -235,27 +235,29 @@ Global Flags: --mesh string mesh to use ``` -### kumactl install postgres-schema +### kumactl install database-schema ``` -Install Kuma on Kubernetes. +Install Kuma schema on DB. Usage: - kumactl install [command] + kumactl install database-schema [flags] -Available Commands: - control-plane Install Kuma Control Plane on Kubernetes - database-schema Install Kuma schema on DB. +Examples: +1. kumactl install database-schema --target=postgres | PGPASSWORD=mysecretpassword psql -h localhost -U postgres +2. sql_file=$(mktemp) ; \ +kumactl install database-schema --target=postgres >$sql_file ; \ +psql --host=localhost --username=postgres --password --file=$sql_file ; \ +rm $sql_file Flags: - -h, --help help for install + -h, --help help for database-schema + --target string Database type: one of postgres (default "postgres") Global Flags: --config-file string path to the configuration file to use --log-level string log level: one of off|info|debug (default "off") --mesh string mesh to use - -Use "kumactl install [command] --help" for more information about a command. ``` ## kumactl get diff --git a/install/postgres/README.md b/install/postgres/README.md index 6dafac7ba777..69c9b47efc56 100644 --- a/install/postgres/README.md +++ b/install/postgres/README.md @@ -1,8 +1,8 @@ ## Postgres installation -You can install Kuma on Postgres DB with following command: +Run following command for installation examples: ```bash -kumactl install postgres-schema | PGPASSWORD=mysecretpassword psql -h localhost -U postgres +kumactl install database-schema --help ``` ### Schema diff --git a/tools/docs/kumactl/gen_help.sh b/tools/docs/kumactl/gen_help.sh index cfb9dac4638f..794dbe28ec57 100755 --- a/tools/docs/kumactl/gen_help.sh +++ b/tools/docs/kumactl/gen_help.sh @@ -35,7 +35,7 @@ gen_help kumactl config control-planes remove gen_help kumactl config control-planes switch gen_help kumactl install gen_help kumactl install control-plane -gen_help kumactl install postgres-schema +gen_help kumactl install database-schema gen_help kumactl get gen_help kumactl get meshes gen_help kumactl get dataplanes diff --git a/tools/postgres/docker-compose.yaml b/tools/postgres/docker-compose.yaml index 33ccaef0bb74..d77777089afb 100644 --- a/tools/postgres/docker-compose.yaml +++ b/tools/postgres/docker-compose.yaml @@ -10,4 +10,4 @@ services: ports: - ${KUMA_STORE_POSTGRES_PORT:-15432}:5432 volumes: - - ../../app/kumactl/data/install/universal/control-plane/postgres/resource.sql:/docker-entrypoint-initdb.d/init.sql \ No newline at end of file + - ../../app/kumactl/cmd/install/testdata/postgres_schema.golden.sql:/docker-entrypoint-initdb.d/init.sql \ No newline at end of file