From 9b1dde036bfe93ac9a1281673880c7ee7c2b4d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Salo=C5=88?= Date: Sun, 18 Jan 2026 18:41:21 +0100 Subject: [PATCH] updated sdk for acl changes --- CHANGELOG.md | 10 ++++++++++ go.mod | 4 ++-- go.sum | 8 ++------ src/cmd/projectImport.go | 7 ++++--- src/cmd/projectServiceImport.go | 7 ++++--- src/cmd/servicePush.go | 7 +------ src/cmd/servicePushDeployShared.go | 4 ++-- src/entity/container.go | 2 +- src/entity/repository/org.go | 2 +- src/entity/repository/project.go | 3 +-- src/entity/repository/service.go | 8 +++++--- src/serviceLogs/handler_getServiceLogUrl.go | 17 +++-------------- src/serviceLogs/handler_printLogs.go | 4 ++-- src/serviceLogs/handler_ws.go | 2 +- 14 files changed, 39 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c917c320..c2d88103 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v1.0.56] - 2026-01-20 + +### Changed +- updated `zerops-go` sdk to the latest version with support for new API changes caused by RBAC/ACL system + +## [v1.0.55] - 2025-10-08 + +### Added +- `vpn clear` and `vpn key` commands + ## [v1.0.54] - 2025-09-17 ### Fixed diff --git a/go.mod b/go.mod index cca297bf..2a45cc81 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module github.com/zeropsio/zcli go 1.24 -require github.com/zeropsio/zerops-go v1.0.14 +require github.com/zeropsio/zerops-go v1.0.16 require ( github.com/charmbracelet/bubbles v0.20.0 @@ -21,6 +21,7 @@ require ( github.com/stretchr/testify v1.10.0 golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 golang.org/x/term v0.28.0 + golang.org/x/text v0.21.0 golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6 gopkg.in/yaml.v3 v3.0.1 ) @@ -57,6 +58,5 @@ require ( golang.org/x/crypto v0.32.0 // indirect golang.org/x/sync v0.11.0 // indirect golang.org/x/sys v0.30.0 // indirect - golang.org/x/text v0.21.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect ) diff --git a/go.sum b/go.sum index 59b0cb4b..74b3e231 100644 --- a/go.sum +++ b/go.sum @@ -107,12 +107,8 @@ github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSW github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/zeropsio/zerops-go v1.0.12 h1:tOuvxFS0vnaX7wkuVxONuhmL9WjIUzuRp4kMxqOl8PE= -github.com/zeropsio/zerops-go v1.0.12/go.mod h1:Nuqf1xWt53IRLyVoXgR4hF4ICc9jlfOfQgnN3ZhJR3E= -github.com/zeropsio/zerops-go v1.0.13 h1:uAE9VsL8N3pEwuf3F+zcZxL0R8ASlIvWJ3H7hbq0xFs= -github.com/zeropsio/zerops-go v1.0.13/go.mod h1:Nuqf1xWt53IRLyVoXgR4hF4ICc9jlfOfQgnN3ZhJR3E= -github.com/zeropsio/zerops-go v1.0.14 h1:+/qQhWoxNj3R2vYc5Y2xDQmhqI2eeSP6VWuKFiLZEFo= -github.com/zeropsio/zerops-go v1.0.14/go.mod h1:Nuqf1xWt53IRLyVoXgR4hF4ICc9jlfOfQgnN3ZhJR3E= +github.com/zeropsio/zerops-go v1.0.16 h1:9k/rdkMxbmBWHea2jENlSLLUXgJevjjoveqxz3y4qto= +github.com/zeropsio/zerops-go v1.0.16/go.mod h1:SY4o+4jAIrsDTwWACooogf1OyY1jNK8NqWBe9KFcjAA= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= diff --git a/src/cmd/projectImport.go b/src/cmd/projectImport.go index bf2be76f..45852e5b 100644 --- a/src/cmd/projectImport.go +++ b/src/cmd/projectImport.go @@ -10,6 +10,7 @@ import ( "github.com/zeropsio/zcli/src/uxHelpers" "github.com/zeropsio/zcli/src/yamlReader" "github.com/zeropsio/zerops-go/dto/input/body" + "github.com/zeropsio/zerops-go/dto/input/path" "github.com/zeropsio/zerops-go/types" "github.com/zeropsio/zerops-go/types/uuid" ) @@ -50,11 +51,11 @@ func projectImportCmd() *cmdBuilder.Cmd { } } - importProjectResponse, err := cmdData.RestApiClient.PostProjectImport( + importProjectResponse, err := cmdData.RestApiClient.PostClientProjectImport( ctx, + path.ClientId{Id: orgId}, body.ProjectImport{ - ClientId: orgId, - Yaml: types.Text(yamlContent), + Yaml: types.Text(yamlContent), }, ) if err != nil { diff --git a/src/cmd/projectServiceImport.go b/src/cmd/projectServiceImport.go index 8819aa89..613d7290 100644 --- a/src/cmd/projectServiceImport.go +++ b/src/cmd/projectServiceImport.go @@ -9,6 +9,7 @@ import ( "github.com/zeropsio/zcli/src/uxHelpers" "github.com/zeropsio/zcli/src/yamlReader" "github.com/zeropsio/zerops-go/dto/input/body" + "github.com/zeropsio/zerops-go/dto/input/path" "github.com/zeropsio/zerops-go/types" ) @@ -45,11 +46,11 @@ func projectServiceImportCmd() *cmdBuilder.Cmd { } } - importServiceResponse, err := cmdData.RestApiClient.PostServiceStackImport( + importServiceResponse, err := cmdData.RestApiClient.PostProjectServiceStackImport( ctx, + path.ProjectId{Id: project.Id}, body.ServiceStackImport{ - ProjectId: project.Id, - Yaml: types.Text(yamlContent), + Yaml: types.Text(yamlContent), }, ) if err != nil { diff --git a/src/cmd/servicePush.go b/src/cmd/servicePush.go index 196235d9..5dc4d084 100644 --- a/src/cmd/servicePush.go +++ b/src/cmd/servicePush.go @@ -203,12 +203,7 @@ func servicePushCmd() *cmdBuilder.Cmd { return err } - guiHost := cmdData. - CliStorage. - Data(). - RegionData. - GuiAddress. - OrDefault("app.zerops.io") + guiHost := cmdData.CliStorage.Data().RegionData.GuiAddress.OrDefault("app.zerops.io") var buildPhase bool var preparePhase bool diff --git a/src/cmd/servicePushDeployShared.go b/src/cmd/servicePushDeployShared.go index 1b0e6422..86010d88 100644 --- a/src/cmd/servicePushDeployShared.go +++ b/src/cmd/servicePushDeployShared.go @@ -27,10 +27,10 @@ func createAppVersion( service entity.Service, versionName string, ) (output.PostAppVersion, error) { - appVersionResponse, err := restApiClient.PostAppVersion( + appVersionResponse, err := restApiClient.PostServiceStackAppVersion( ctx, + path.ServiceStackId{Id: service.Id}, body.PostAppVersion{ - ServiceStackId: service.Id, Name: func() types.StringNull { if versionName != "" { return types.NewStringNull(versionName) diff --git a/src/entity/container.go b/src/entity/container.go index 3386d797..2e3a6ba3 100644 --- a/src/entity/container.go +++ b/src/entity/container.go @@ -11,7 +11,7 @@ type Container struct { OrgId uuid.ClientId ProjectId uuid.ProjectId ServiceId uuid.ServiceStackId - Status enum.ContainerStatusEnum + Status *enum.ContainerStatusEnum Number types.Int Name types.StringNull Hostname types.StringNull diff --git a/src/entity/repository/org.go b/src/entity/repository/org.go index 0a41c7da..ba64ca1f 100644 --- a/src/entity/repository/org.go +++ b/src/entity/repository/org.go @@ -51,7 +51,7 @@ func GetOrgById( return org, nil } -func orgFromEsSearch(esClientUser output.ClientUserExtra) entity.Org { +func orgFromEsSearch(esClientUser output.ClientUserExtraWithClientLight) entity.Org { return entity.Org{ Id: esClientUser.ClientId, Name: esClientUser.Client.AccountName, diff --git a/src/entity/repository/project.go b/src/entity/repository/project.go index 24eb6e85..ac39bddc 100644 --- a/src/entity/repository/project.go +++ b/src/entity/repository/project.go @@ -75,7 +75,6 @@ func PostProject( post entity.PostProject, ) (entity.Project, error) { postBody := body.PostProject{ - ClientId: post.OrgId, Name: post.Name, Mode: &post.Mode, TagList: post.Tags, @@ -85,7 +84,7 @@ func PostProject( if postBody.TagList == nil { postBody.TagList = make(types.StringArray, 0) } - response, err := restApiClient.PostProject(ctx, postBody) + response, err := restApiClient.PostClientProject(ctx, path.ClientId{Id: post.OrgId}, postBody) if err != nil { return entity.Project{}, err } diff --git a/src/entity/repository/service.go b/src/entity/repository/service.go index 6fe03211..6891914c 100644 --- a/src/entity/repository/service.go +++ b/src/entity/repository/service.go @@ -133,7 +133,6 @@ func PostGenericService( post entity.PostService, ) (entity.Process, entity.Service, error) { postBody := body.PostStandardServiceStack{ - ProjectId: post.ProjectId, Name: post.Name, Mode: &post.Mode, UserDataEnvFile: post.EnvFile, @@ -141,9 +140,12 @@ func PostGenericService( EnvIsolation: post.EnvIsolation, SshIsolation: post.SshIsolation, } - response, err := restApiClient.PostServiceStack( + response, err := restApiClient.PostProjectServiceStack( ctx, - path.ServiceStackServiceStackTypeVersionId{ServiceStackTypeVersionId: "runtime"}, + path.ServiceStackServiceStackTypeVersionId{ + Id: post.ProjectId, + ServiceStackTypeVersionId: "runtime", + }, postBody, ) if err != nil { diff --git a/src/serviceLogs/handler_getServiceLogUrl.go b/src/serviceLogs/handler_getServiceLogUrl.go index 4c482f71..df82c4d1 100644 --- a/src/serviceLogs/handler_getServiceLogUrl.go +++ b/src/serviceLogs/handler_getServiceLogUrl.go @@ -2,14 +2,12 @@ package serviceLogs import ( "context" - "strings" + "net/http" "github.com/pkg/errors" - "github.com/zeropsio/zerops-go/dto/input/query" - "github.com/zeropsio/zerops-go/dto/output" - "github.com/zeropsio/zcli/src/i18n" "github.com/zeropsio/zerops-go/dto/input/path" + "github.com/zeropsio/zerops-go/dto/input/query" "github.com/zeropsio/zerops-go/types/uuid" ) @@ -23,14 +21,5 @@ func (h *Handler) getServiceLogResData(ctx context.Context, projectId uuid.Proje if err != nil { return "", "", errors.Errorf("%s %v", i18n.T(i18n.LogAccessFailed), err) } - method, url := getLogRequestData(resOutput) - return method, url, nil -} - -func getLogRequestData(resOutput output.ProjectLog) (string, string) { - outputUrl := string(resOutput.Url) - urlData := strings.Split(outputUrl, " ") - method, url := urlData[0], urlData[1] - - return method, url + return http.MethodGet, resOutput.Url.String(), nil } diff --git a/src/serviceLogs/handler_printLogs.go b/src/serviceLogs/handler_printLogs.go index 1d141a0c..d3a92174 100644 --- a/src/serviceLogs/handler_printLogs.go +++ b/src/serviceLogs/handler_printLogs.go @@ -23,7 +23,7 @@ func (h *Handler) printLogs( query := makeQueryParams(inputs, serviceId, containerId) if inputs.mode == RESPONSE { - err = h.getLogs(ctx, method, HTTPS+url+query, inputs.format, inputs.formatTemplate, inputs.mode) + err = h.getLogs(ctx, method, url+query, inputs.format, inputs.formatTemplate, inputs.mode) if err != nil { return err } @@ -67,5 +67,5 @@ func getDesc(mode string) int { func getWsUrl(apiUrl string) string { urlSplit := strings.Split(apiUrl, "?") url, token := urlSplit[0], urlSplit[1] - return url + "/stream?" + token + return strings.ReplaceAll(url, HTTPS, WSS) + "/stream?" + token } diff --git a/src/serviceLogs/handler_ws.go b/src/serviceLogs/handler_ws.go index 49762d1f..0881c8b8 100644 --- a/src/serviceLogs/handler_ws.go +++ b/src/serviceLogs/handler_ws.go @@ -49,7 +49,7 @@ func (h *Handler) updateUri(uri, query string) string { if h.lastMsgId != "" { from = fmt.Sprintf("&from=%s", h.lastMsgId) } - return WSS + uri + query + from + return uri + query + from } func (h *Handler) receiveHandler(connection *websocket.Conn, format, formatTemplate string, done chan error) {