From 41d1d390ef73e9dd460ed125c35cfb7a4735afca Mon Sep 17 00:00:00 2001 From: Siddarth-Baldwa Date: Tue, 24 Dec 2024 18:54:28 +0000 Subject: [PATCH] Docs changes for DB Audit Logging --- .../db_audit_log_exporter.go | 16 +++---- cmd/db_audit_logs_exporter_test.go | 18 +++++++- docs/ybm_cluster.md | 1 + docs/ybm_cluster_db-audit-logging.md | 40 +++++++++++++++++ docs/ybm_cluster_db-audit-logging_describe.md | 36 +++++++++++++++ docs/ybm_cluster_db-audit-logging_disable.md | 37 ++++++++++++++++ docs/ybm_cluster_db-audit-logging_enable.md | 44 +++++++++++++++++++ docs/ybm_cluster_db-audit-logging_update.md | 44 +++++++++++++++++++ go.mod | 2 +- go.sum | 2 + 10 files changed, 226 insertions(+), 14 deletions(-) create mode 100644 docs/ybm_cluster_db-audit-logging.md create mode 100644 docs/ybm_cluster_db-audit-logging_describe.md create mode 100644 docs/ybm_cluster_db-audit-logging_disable.md create mode 100644 docs/ybm_cluster_db-audit-logging_enable.md create mode 100644 docs/ybm_cluster_db-audit-logging_update.md diff --git a/cmd/cluster/audit-log-exporter/db_audit_log_exporter.go b/cmd/cluster/audit-log-exporter/db_audit_log_exporter.go index 6354613..b60a96b 100644 --- a/cmd/cluster/audit-log-exporter/db_audit_log_exporter.go +++ b/cmd/cluster/audit-log-exporter/db_audit_log_exporter.go @@ -275,7 +275,7 @@ func init() { enableDbAuditLoggingCmd.Flags().SortFlags = false enableDbAuditLoggingCmd.Flags().String("integration-name", "", "[REQUIRED] Name of the Integration") enableDbAuditLoggingCmd.MarkFlagRequired("integration-name") - enableDbAuditLoggingCmd.Flags().StringToString("ysql-config", nil, `[REQUIRED] The ysql config to setup DB auditting + enableDbAuditLoggingCmd.Flags().StringToString("ysql-config", nil, `[REQUIRED] The ysql config to setup DB audit logging Please provide key value pairs as follows: log_catalog=,log_level=,log_client=,log_parameter=, log_relation=,log_statement_once=`) @@ -284,32 +284,26 @@ func init() { Please provide key value pairs as follows: statement_classes=READ,WRITE,MISC`) enableDbAuditLoggingCmd.MarkFlagRequired("statement_classes") - enableDbAuditLoggingCmd.Flags().String("cluster-name", "", "[REQUIRED] The cluster name to assign DB auditting") - enableDbAuditLoggingCmd.MarkFlagRequired("cluster-name") DbAuditLoggingCmd.AddCommand(describeDbAuditLoggingCmd) describeDbAuditLoggingCmd.Flags().SortFlags = false - describeDbAuditLoggingCmd.Flags().String("cluster-name", "", "[REQUIRED] The cluster name to list DB audit export config") - describeDbAuditLoggingCmd.MarkFlagRequired("cluster-name") DbAuditLoggingCmd.AddCommand(updateDbAuditLoggingCmd) updateDbAuditLoggingCmd.Flags().SortFlags = false updateDbAuditLoggingCmd.Flags().String("integration-name", "", "[REQUIRED] Name of the Integration") updateDbAuditLoggingCmd.MarkFlagRequired("integration-name") - updateDbAuditLoggingCmd.Flags().StringToString("ysql-config", nil, `The ysql config to setup DB auditting + updateDbAuditLoggingCmd.Flags().StringToString("ysql-config", nil, `[REQUIRED] The ysql config to setup DB audit logging Please provide key value pairs as follows: log_catalog=,log_level=,log_client=,log_parameter=, log_relation=,log_statement_once=`) - updateDbAuditLoggingCmd.Flags().String("statement_classes", "", `The ysql config statement classes + updateDbAuditLoggingCmd.MarkFlagRequired("ysql-config") + updateDbAuditLoggingCmd.Flags().String("statement_classes", "", `[REQUIRED] The ysql config statement classes Please provide key value pairs as follows: statement_classes=READ,WRITE,MISC`) - updateDbAuditLoggingCmd.Flags().String("cluster-name", "", "[REQUIRED] The cluster name to assign DB auditting") - updateDbAuditLoggingCmd.MarkFlagRequired("cluster-name") + updateDbAuditLoggingCmd.MarkFlagRequired("statement_classes") DbAuditLoggingCmd.AddCommand(disableDbAuditLoggingCmd) disableDbAuditLoggingCmd.Flags().SortFlags = false - disableDbAuditLoggingCmd.Flags().String("cluster-name", "", "[REQUIRED] The cluster name to assign DB auditting") - disableDbAuditLoggingCmd.MarkFlagRequired("cluster-name") disableDbAuditLoggingCmd.Flags().BoolP("force", "f", false, "Bypass the prompt for non-interactive usage") } diff --git a/cmd/db_audit_logs_exporter_test.go b/cmd/db_audit_logs_exporter_test.go index 1a99106..c44dbc3 100644 --- a/cmd/db_audit_logs_exporter_test.go +++ b/cmd/db_audit_logs_exporter_test.go @@ -305,7 +305,21 @@ log-statement-once false`))) session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter) Expect(err).NotTo(HaveOccurred()) session.Wait(2) - Expect(session.Err).Should(gbytes.Say(`\bError: required flag\(s\) "integration-name", "cluster-name" not set\b`)) + Expect(session.Err).Should(gbytes.Say(`\bError: required flag\(s\) "integration-name", "ysql-config", "statement_classes", "cluster-name" not set\b`)) + session.Kill() + + cmd = exec.Command(compiledCLIPath, "cluster", "db-audit-logging", "update", "--cluster-name", "stunning-sole") + session, err = gexec.Start(cmd, GinkgoWriter, GinkgoWriter) + Expect(err).NotTo(HaveOccurred()) + session.Wait(2) + Expect(session.Err).Should(gbytes.Say(`\bError: required flag\(s\) "integration-name", "ysql-config", "statement_classes" not set\b`)) + session.Kill() + + cmd = exec.Command(compiledCLIPath, "cluster", "db-audit-logging", "update", "--cluster-name", "stunning-sole", "--integration-name", "datadog-tp") + session, err = gexec.Start(cmd, GinkgoWriter, GinkgoWriter) + Expect(err).NotTo(HaveOccurred()) + session.Wait(2) + Expect(session.Err).Should(gbytes.Say(`\bError: required flag\(s\) "ysql-config", "statement_classes" not set\b`)) session.Kill() }) It("should return required log setting when not set", func() { @@ -335,7 +349,7 @@ log-statement-once false`))) ghttp.RespondWithJSONEncodedPtr(&statusCode, responseIntegrationList), ), ) - cmd := exec.Command(compiledCLIPath, "cluster", "db-audit-logging", "update", "--cluster-name", "stunning-sole", "--integration-name", "datadog-tp", "--ysql-config", "log_catalog=true,log_client=true,log_level=NOTICE,log_parameter=false,log_relation=false") + cmd := exec.Command(compiledCLIPath, "cluster", "db-audit-logging", "update", "--cluster-name", "stunning-sole", "--integration-name", "datadog-tp", "--ysql-config", "log_catalog=true,log_client=true,log_level=NOTICE,log_parameter=false,log_relation=false", "--statement_classes", "") session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter) Expect(err).NotTo(HaveOccurred()) session.Wait(2) diff --git a/docs/ybm_cluster.md b/docs/ybm_cluster.md index 00b217b..1d22384 100644 --- a/docs/ybm_cluster.md +++ b/docs/ybm_cluster.md @@ -34,6 +34,7 @@ ybm cluster [flags] * [ybm](ybm.md) - ybm - Effortlessly manage your DB infrastructure on YugabyteDB Aeon (DBaaS) from command line! * [ybm cluster cert](ybm_cluster_cert.md) - Get the root CA certificate * [ybm cluster create](ybm_cluster_create.md) - Create a cluster +* [ybm cluster db-audit-logging](ybm_cluster_db-audit-logging.md) - Configure Database Audit Logging for your Cluster. * [ybm cluster db-query-logging](ybm_cluster_db-query-logging.md) - Configure Database Query Logging for your Cluster. * [ybm cluster delete](ybm_cluster_delete.md) - Delete a cluster * [ybm cluster describe](ybm_cluster_describe.md) - Describe a cluster diff --git a/docs/ybm_cluster_db-audit-logging.md b/docs/ybm_cluster_db-audit-logging.md new file mode 100644 index 0000000..52f7791 --- /dev/null +++ b/docs/ybm_cluster_db-audit-logging.md @@ -0,0 +1,40 @@ +## ybm cluster db-audit-logging + +Configure Database Audit Logging for your Cluster. + +### Synopsis + +Configure Database Audit Logging for your Cluster. + +``` +ybm cluster db-audit-logging [flags] +``` + +### Options + +``` + -c, --cluster-name string [REQUIRED] The name of the cluster. + -h, --help help for db-audit-logging +``` + +### Options inherited from parent commands + +``` + -a, --apiKey string YugabyteDB Aeon account API key + --config string config file (default is $HOME/.ybm-cli.yaml) + --debug Use debug mode, same as --logLevel debug + -l, --logLevel string Select the desired log level format(info). Default to info + --no-color Disable colors in output , default to false + -o, --output string Select the desired output format (table, json, pretty). Default to table + --timeout duration Wait command timeout, example: 5m, 1h. (default 168h0m0s) + --wait Wait until the task is completed, otherwise it will exit immediately, default to false +``` + +### SEE ALSO + +* [ybm cluster](ybm_cluster.md) - Manage cluster operations +* [ybm cluster db-audit-logging describe](ybm_cluster_db-audit-logging_describe.md) - Describe Database Audit Logging configuration +* [ybm cluster db-audit-logging disable](ybm_cluster_db-audit-logging_disable.md) - Disable Database Audit Logging +* [ybm cluster db-audit-logging enable](ybm_cluster_db-audit-logging_enable.md) - Enable Database Audit Logging +* [ybm cluster db-audit-logging update](ybm_cluster_db-audit-logging_update.md) - Update Database Audit Logging Configuration + diff --git a/docs/ybm_cluster_db-audit-logging_describe.md b/docs/ybm_cluster_db-audit-logging_describe.md new file mode 100644 index 0000000..923dfe7 --- /dev/null +++ b/docs/ybm_cluster_db-audit-logging_describe.md @@ -0,0 +1,36 @@ +## ybm cluster db-audit-logging describe + +Describe Database Audit Logging configuration + +### Synopsis + +Describe Database Audit Logging configuration + +``` +ybm cluster db-audit-logging describe [flags] +``` + +### Options + +``` + -h, --help help for describe +``` + +### Options inherited from parent commands + +``` + -a, --apiKey string YugabyteDB Aeon account API key + -c, --cluster-name string [REQUIRED] The name of the cluster. + --config string config file (default is $HOME/.ybm-cli.yaml) + --debug Use debug mode, same as --logLevel debug + -l, --logLevel string Select the desired log level format(info). Default to info + --no-color Disable colors in output , default to false + -o, --output string Select the desired output format (table, json, pretty). Default to table + --timeout duration Wait command timeout, example: 5m, 1h. (default 168h0m0s) + --wait Wait until the task is completed, otherwise it will exit immediately, default to false +``` + +### SEE ALSO + +* [ybm cluster db-audit-logging](ybm_cluster_db-audit-logging.md) - Configure Database Audit Logging for your Cluster. + diff --git a/docs/ybm_cluster_db-audit-logging_disable.md b/docs/ybm_cluster_db-audit-logging_disable.md new file mode 100644 index 0000000..c3aef43 --- /dev/null +++ b/docs/ybm_cluster_db-audit-logging_disable.md @@ -0,0 +1,37 @@ +## ybm cluster db-audit-logging disable + +Disable Database Audit Logging + +### Synopsis + +Disable Database Audit Logging, if enabled + +``` +ybm cluster db-audit-logging disable [flags] +``` + +### Options + +``` + -f, --force Bypass the prompt for non-interactive usage + -h, --help help for disable +``` + +### Options inherited from parent commands + +``` + -a, --apiKey string YugabyteDB Aeon account API key + -c, --cluster-name string [REQUIRED] The name of the cluster. + --config string config file (default is $HOME/.ybm-cli.yaml) + --debug Use debug mode, same as --logLevel debug + -l, --logLevel string Select the desired log level format(info). Default to info + --no-color Disable colors in output , default to false + -o, --output string Select the desired output format (table, json, pretty). Default to table + --timeout duration Wait command timeout, example: 5m, 1h. (default 168h0m0s) + --wait Wait until the task is completed, otherwise it will exit immediately, default to false +``` + +### SEE ALSO + +* [ybm cluster db-audit-logging](ybm_cluster_db-audit-logging.md) - Configure Database Audit Logging for your Cluster. + diff --git a/docs/ybm_cluster_db-audit-logging_enable.md b/docs/ybm_cluster_db-audit-logging_enable.md new file mode 100644 index 0000000..6963e10 --- /dev/null +++ b/docs/ybm_cluster_db-audit-logging_enable.md @@ -0,0 +1,44 @@ +## ybm cluster db-audit-logging enable + +Enable Database Audit Logging + +### Synopsis + +Enable Database Audit Logging + +``` +ybm cluster db-audit-logging enable [flags] +``` + +### Options + +``` + --integration-name string [REQUIRED] Name of the Integration + --ysql-config stringToString [REQUIRED] The ysql config to setup DB audit logging + Please provide key value pairs as follows: + log_catalog=,log_level=,log_client=,log_parameter=, + log_relation=,log_statement_once= (default []) + --statement_classes string [REQUIRED] The ysql config statement classes + Please provide key value pairs as follows: + statement_classes=READ,WRITE,MISC + -h, --help help for enable +``` + +### Options inherited from parent commands + +``` + -a, --apiKey string YugabyteDB Aeon account API key + -c, --cluster-name string [REQUIRED] The name of the cluster. + --config string config file (default is $HOME/.ybm-cli.yaml) + --debug Use debug mode, same as --logLevel debug + -l, --logLevel string Select the desired log level format(info). Default to info + --no-color Disable colors in output , default to false + -o, --output string Select the desired output format (table, json, pretty). Default to table + --timeout duration Wait command timeout, example: 5m, 1h. (default 168h0m0s) + --wait Wait until the task is completed, otherwise it will exit immediately, default to false +``` + +### SEE ALSO + +* [ybm cluster db-audit-logging](ybm_cluster_db-audit-logging.md) - Configure Database Audit Logging for your Cluster. + diff --git a/docs/ybm_cluster_db-audit-logging_update.md b/docs/ybm_cluster_db-audit-logging_update.md new file mode 100644 index 0000000..ef1fa04 --- /dev/null +++ b/docs/ybm_cluster_db-audit-logging_update.md @@ -0,0 +1,44 @@ +## ybm cluster db-audit-logging update + +Update Database Audit Logging Configuration + +### Synopsis + +Update Database Audit Logging Configuration + +``` +ybm cluster db-audit-logging update [flags] +``` + +### Options + +``` + --integration-name string [REQUIRED] Name of the Integration + --ysql-config stringToString [REQUIRED] The ysql config to setup DB audit logging + Please provide key value pairs as follows: + log_catalog=,log_level=,log_client=,log_parameter=, + log_relation=,log_statement_once= (default []) + --statement_classes string [REQUIRED] The ysql config statement classes + Please provide key value pairs as follows: + statement_classes=READ,WRITE,MISC + -h, --help help for update +``` + +### Options inherited from parent commands + +``` + -a, --apiKey string YugabyteDB Aeon account API key + -c, --cluster-name string [REQUIRED] The name of the cluster. + --config string config file (default is $HOME/.ybm-cli.yaml) + --debug Use debug mode, same as --logLevel debug + -l, --logLevel string Select the desired log level format(info). Default to info + --no-color Disable colors in output , default to false + -o, --output string Select the desired output format (table, json, pretty). Default to table + --timeout duration Wait command timeout, example: 5m, 1h. (default 168h0m0s) + --wait Wait until the task is completed, otherwise it will exit immediately, default to false +``` + +### SEE ALSO + +* [ybm cluster db-audit-logging](ybm_cluster_db-audit-logging.md) - Configure Database Audit Logging for your Cluster. + diff --git a/go.mod b/go.mod index f8fd3b9..b57afdf 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/spf13/cobra v1.8.0 github.com/spf13/viper v1.17.0 github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 - github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241219183048-50fe86c058d8 + github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241224115148-e3b391db3af9 golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 golang.org/x/mod v0.20.0 golang.org/x/term v0.25.0 diff --git a/go.sum b/go.sum index 078a156..7bb6913 100644 --- a/go.sum +++ b/go.sum @@ -284,6 +284,8 @@ github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 h1 github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA= github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241219183048-50fe86c058d8 h1:criIjOTBfBOy0cZ23Qh2sOI0KLL3P4WKutnUhovUHPA= github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241219183048-50fe86c058d8/go.mod h1:5vW0xIzIZw+1djkiWKx0qqNmqbRBSf4mjc4qw8lIMik= +github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241224115148-e3b391db3af9 h1:omB8P+cKd/t5CEvgXCYoiCFg1SU+k4P0Ig28NqPrizw= +github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241224115148-e3b391db3af9/go.mod h1:5vW0xIzIZw+1djkiWKx0qqNmqbRBSf4mjc4qw8lIMik= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=