From 20b80a11d0e672f303aeb690f9dd4bcae74fa795 Mon Sep 17 00:00:00 2001 From: Jan Saidl Date: Wed, 12 Oct 2022 08:45:43 +0200 Subject: [PATCH] z2457 - fix missing clientId in get logs on appVersion and container --- CHANGELOG.md | 3 ++- src/cliAction/serviceLogs/handler_getAppVersion.go | 8 +------- src/cliAction/serviceLogs/handler_getContainerId.go | 7 +------ src/cliAction/serviceLogs/handler_run.go | 5 +++-- 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0fca815..3042fd6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [v0.12.14] - 2022-10-12 ### Fixed -- support absolute path for import script +- support absolute path for import script +- fix missing clientId in get logs on appVersion and container ## [v0.12.13] - 2022-10-06 diff --git a/src/cliAction/serviceLogs/handler_getAppVersion.go b/src/cliAction/serviceLogs/handler_getAppVersion.go index cf7debd4..0d6d232d 100644 --- a/src/cliAction/serviceLogs/handler_getAppVersion.go +++ b/src/cliAction/serviceLogs/handler_getAppVersion.go @@ -7,7 +7,6 @@ import ( "time" "github.com/zeropsio/zcli/src/i18n" - "github.com/zeropsio/zcli/src/utils/projectService" "github.com/zeropsio/zcli/src/utils/sdkConfig" "github.com/zeropsio/zerops-go/dto/input/body" "github.com/zeropsio/zerops-go/sdk" @@ -15,18 +14,13 @@ import ( "github.com/zeropsio/zerops-go/types" ) -func (h *Handler) getAppVersionServiceId(ctx context.Context, sdkConfig sdkConfig.Config, serviceId string) (string, error) { +func (h *Handler) getAppVersionServiceId(ctx context.Context, sdkConfig sdkConfig.Config, clientId string, serviceId string) (string, error) { zdk := sdk.New( sdkBase.DefaultConfig(sdkBase.WithCustomEndpoint(sdkConfig.RegionUrl)), &http.Client{Timeout: 1 * time.Minute}, ) authorizedSdk := sdk.AuthorizeSdk(zdk, sdkConfig.Token) - clientId, err := projectService.GetClientId(ctx, h.apiGrpcClient) - if err != nil { - return "", err - } - var searchData []body.EsSearchItem searchData = append(searchData, body.EsSearchItem{ Name: "clientId", diff --git a/src/cliAction/serviceLogs/handler_getContainerId.go b/src/cliAction/serviceLogs/handler_getContainerId.go index 5159a6cc..ed682d49 100644 --- a/src/cliAction/serviceLogs/handler_getContainerId.go +++ b/src/cliAction/serviceLogs/handler_getContainerId.go @@ -7,7 +7,6 @@ import ( "time" "github.com/zeropsio/zcli/src/i18n" - "github.com/zeropsio/zcli/src/utils/projectService" "github.com/zeropsio/zcli/src/utils/sdkConfig" "github.com/zeropsio/zerops-go/dto/input/body" "github.com/zeropsio/zerops-go/sdk" @@ -15,17 +14,13 @@ import ( "github.com/zeropsio/zerops-go/types" ) -func (h *Handler) getContainerId(ctx context.Context, sdkConfig sdkConfig.Config, serviceId string, containerIndex int) (string, error) { +func (h *Handler) getContainerId(ctx context.Context, sdkConfig sdkConfig.Config, clientId string, serviceId string, containerIndex int) (string, error) { zdk := sdk.New( sdkBase.DefaultConfig(sdkBase.WithCustomEndpoint(sdkConfig.RegionUrl)), &http.Client{Timeout: 1 * time.Minute}, ) authorizedSdk := sdk.AuthorizeSdk(zdk, sdkConfig.Token) - clientId, err := projectService.GetClientId(ctx, h.apiGrpcClient) - if err != nil { - return "", err - } var searchData []body.EsSearchItem searchData = append(searchData, body.EsSearchItem{ diff --git a/src/cliAction/serviceLogs/handler_run.go b/src/cliAction/serviceLogs/handler_run.go index b55da4ea..2b1f07f3 100644 --- a/src/cliAction/serviceLogs/handler_run.go +++ b/src/cliAction/serviceLogs/handler_run.go @@ -3,6 +3,7 @@ package serviceLogs import ( "context" "fmt" + "github.com/zeropsio/zcli/src/i18n" "github.com/zeropsio/zcli/src/utils/projectService" ) @@ -37,7 +38,7 @@ func (h *Handler) Run(ctx context.Context, config RunConfig) error { containerId := "" // defined by user, can be 1 or higher if containerIndex > 0 { - containerId, err = h.getContainerId(ctx, h.sdkConfig, serviceId, containerIndex) + containerId, err = h.getContainerId(ctx, h.sdkConfig, service.Project.ClientId, serviceId, containerIndex) if err != nil { return err } @@ -45,7 +46,7 @@ func (h *Handler) Run(ctx context.Context, config RunConfig) error { logServiceId := serviceId if source == BUILD { - logServiceId, err = h.getAppVersionServiceId(ctx, h.sdkConfig, serviceId) + logServiceId, err = h.getAppVersionServiceId(ctx, h.sdkConfig, service.Project.ClientId, serviceId) if err != nil { return err }