From f7ccf1727b078c2f83c4fe575546579b711b0bc5 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Wed, 15 Jul 2020 09:11:26 +0000 Subject: [PATCH 1/2] feat(rdb): add GetInstanceLogs method --- internal/namespaces/rdb/v1/rdb_cli.go | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/internal/namespaces/rdb/v1/rdb_cli.go b/internal/namespaces/rdb/v1/rdb_cli.go index 65d973ccc9..775413a1eb 100644 --- a/internal/namespaces/rdb/v1/rdb_cli.go +++ b/internal/namespaces/rdb/v1/rdb_cli.go @@ -48,6 +48,7 @@ func GetGeneratedCommands() *core.Commands { rdbInstanceGetCertificate(), rdbLogPrepare(), rdbLogList(), + rdbLogGet(), rdbInstanceGetMetrics(), rdbSettingsAdd(), rdbSettingsDelete(), @@ -887,11 +888,13 @@ func rdbLogList() *core.Command { ArgSpecs: core.ArgSpecs{ { Name: "instance-id", + Short: `UUID of the instance you want logs of`, Required: true, Positional: true, }, { Name: "order-by", + Short: `Criteria to use when ordering instance logs listing`, Required: false, Positional: false, EnumValues: []string{"created_at_asc", "created_at_desc"}, @@ -909,6 +912,34 @@ func rdbLogList() *core.Command { } } +func rdbLogGet() *core.Command { + return &core.Command{ + Short: `Get specific logs of a given instance`, + Long: `Get specific logs of a given instance.`, + Namespace: "rdb", + Resource: "log", + Verb: "get", + ArgsType: reflect.TypeOf(rdb.GetInstanceLogRequest{}), + ArgSpecs: core.ArgSpecs{ + { + Name: "instance-log-id", + Short: `UUID of the instance_log you want`, + Required: true, + Positional: true, + }, + core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms), + }, + Run: func(ctx context.Context, args interface{}) (i interface{}, e error) { + request := args.(*rdb.GetInstanceLogRequest) + + client := core.ExtractClient(ctx) + api := rdb.NewAPI(client) + return api.GetInstanceLog(request) + + }, + } +} + func rdbInstanceGetMetrics() *core.Command { return &core.Command{ Short: `Get instance metrics`, From f981a2106c13ebdf82247e0a04c786bce22a4ac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20L=C3=A9one?= Date: Wed, 15 Jul 2020 11:26:41 +0200 Subject: [PATCH 2/2] fix all usage --- .../test-all-usage-rdb-log-get-usage.golden | 19 +++++++++++++++++++ .../test-all-usage-rdb-log-list-usage.golden | 4 ++-- .../test-all-usage-rdb-log-usage.golden | 1 + 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 cmd/scw/testdata/test-all-usage-rdb-log-get-usage.golden diff --git a/cmd/scw/testdata/test-all-usage-rdb-log-get-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-log-get-usage.golden new file mode 100644 index 0000000000..819f8cb056 --- /dev/null +++ b/cmd/scw/testdata/test-all-usage-rdb-log-get-usage.golden @@ -0,0 +1,19 @@ +🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 +πŸŸ₯πŸŸ₯πŸŸ₯ STDERR️️ πŸŸ₯πŸŸ₯πŸŸ₯️ +Get specific logs of a given instance. + +USAGE: + scw rdb log get [arg=value ...] + +ARGS: + instance-log-id UUID of the instance_log you want + [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams) + +FLAGS: + -h, --help help for get + +GLOBAL FLAGS: + -c, --config string The path to the config file + -D, --debug Enable debug mode + -o, --output string Output format: json or human, see 'scw help output' for more info (default "human") + -p, --profile string The config profile to use diff --git a/cmd/scw/testdata/test-all-usage-rdb-log-list-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-log-list-usage.golden index 47850dc443..693f08722d 100644 --- a/cmd/scw/testdata/test-all-usage-rdb-log-list-usage.golden +++ b/cmd/scw/testdata/test-all-usage-rdb-log-list-usage.golden @@ -6,8 +6,8 @@ USAGE: scw rdb log list [arg=value ...] ARGS: - instance-id - [order-by] (created_at_asc | created_at_desc) + instance-id UUID of the instance you want logs of + [order-by] Criteria to use when ordering instance logs listing (created_at_asc | created_at_desc) [region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams) FLAGS: diff --git a/cmd/scw/testdata/test-all-usage-rdb-log-usage.golden b/cmd/scw/testdata/test-all-usage-rdb-log-usage.golden index b7714e9c7a..fe965aea81 100644 --- a/cmd/scw/testdata/test-all-usage-rdb-log-usage.golden +++ b/cmd/scw/testdata/test-all-usage-rdb-log-usage.golden @@ -6,6 +6,7 @@ USAGE: scw rdb log AVAILABLE COMMANDS: + get Get specific logs of a given instance list List available logs of a given instance prepare Prepare logs of a given instance