Skip to content

Commit

Permalink
Merge pull request #102 from zeropsio/z2457
Browse files Browse the repository at this point in the history
z2457 - fix missing clientId in get logs on appVersion and container
  • Loading branch information
jansaidl authored Oct 12, 2022
2 parents e6028d8 + 20b80a1 commit d489529
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 16 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 1 addition & 7 deletions src/cliAction/serviceLogs/handler_getAppVersion.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,20 @@ 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"
"github.com/zeropsio/zerops-go/sdkBase"
"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",
Expand Down
7 changes: 1 addition & 6 deletions src/cliAction/serviceLogs/handler_getContainerId.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,20 @@ 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"
"github.com/zeropsio/zerops-go/sdkBase"
"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{
Expand Down
5 changes: 3 additions & 2 deletions src/cliAction/serviceLogs/handler_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package serviceLogs
import (
"context"
"fmt"

"github.com/zeropsio/zcli/src/i18n"
"github.com/zeropsio/zcli/src/utils/projectService"
)
Expand Down Expand Up @@ -37,15 +38,15 @@ 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
}
}

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
}
Expand Down

0 comments on commit d489529

Please sign in to comment.