Skip to content

Commit

Permalink
z1816 - new zbusiness protobufs and protoc-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalSalon committed Aug 8, 2022
1 parent ff647f1 commit 726559d
Show file tree
Hide file tree
Showing 51 changed files with 7,920 additions and 6,940 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,3 @@ jobs:
- name: Lint
if: ${{ matrix.runLint }}
run: env ${{ matrix.osEnv }} gomodrun golangci-lint run ./cmd/... ./src/... --verbose



1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
include/
zcli.config.yml
zcli.data
tools/npm/node_modules
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ 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).

## [v0.12.0] - 2022-08-08

### Changed
- Updated protobufs to the latest version (**!!!breaking change!!! previous zCLI versions are not compatible and will not work**)
- Updated `protoc-gen` from GitHub to `protoc-gen-go` and `protoc-gen-go-grpc` from GoLang.org

## [v0.11.4] - 2022-07-26
- Enable lowercase formatTemplate values, fix length of timestamps.

Expand Down
6 changes: 3 additions & 3 deletions src/cliAction/buildDeploy/handler.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package buildDeploy

import (
"github.com/zerops-io/zcli/src/proto/business"
"github.com/zerops-io/zcli/src/proto/zBusinessZeropsApiProtocol"
"github.com/zerops-io/zcli/src/utils/archiveClient"
"github.com/zerops-io/zcli/src/utils/httpClient"
"github.com/zerops-io/zcli/src/utils/sdkConfig"
Expand All @@ -27,15 +27,15 @@ type Handler struct {
config Config
httpClient *httpClient.Handler
archClient *archiveClient.Handler
apiGrpcClient business.ZeropsApiProtocolClient
apiGrpcClient zBusinessZeropsApiProtocol.ZBusinessZeropsApiProtocolClient
sdkConfig sdkConfig.Config
}

func New(
config Config,
httpClient *httpClient.Handler,
archClient *archiveClient.Handler,
apiGrpcClient business.ZeropsApiProtocolClient,
apiGrpcClient zBusinessZeropsApiProtocol.ZBusinessZeropsApiProtocolClient,
sdkConfig sdkConfig.Config,
) *Handler {
return &Handler{
Expand Down
7 changes: 3 additions & 4 deletions src/cliAction/buildDeploy/handler_checkInputValues.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import (
"context"
"fmt"

"github.com/zerops-io/zcli/src/proto/business"
"github.com/zerops-io/zcli/src/utils/projectService"

"github.com/zerops-io/zcli/src/i18n"
"github.com/zerops-io/zcli/src/proto/zBusinessZeropsApiProtocol"
"github.com/zerops-io/zcli/src/utils/projectService"
)

func (h *Handler) checkInputValues(ctx context.Context, config RunConfig) (*business.GetServiceStackByNameResponseDto, error) {
func (h *Handler) checkInputValues(ctx context.Context, config RunConfig) (*zBusinessZeropsApiProtocol.GetServiceStackByNameResponseDto, error) {
projectId, err := projectService.GetProjectId(ctx, h.apiGrpcClient, config.ProjectNameOrId, h.sdkConfig)
if err != nil {
return nil, err
Expand Down
12 changes: 6 additions & 6 deletions src/cliAction/buildDeploy/handler_createAppVersion.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ import (
"context"

"github.com/zerops-io/zcli/src/proto"
"github.com/zerops-io/zcli/src/proto/business"
"github.com/zerops-io/zcli/src/proto/zBusinessZeropsApiProtocol"
)

func (h *Handler) createAppVersion(ctx context.Context, config RunConfig, serviceStack *business.GetServiceStackByNameResponseDto) (*business.PostAppVersionResponseDto, error) {
appVersionResponse, err := h.apiGrpcClient.PostAppVersion(ctx, &business.PostAppVersionRequest{
func (h *Handler) createAppVersion(ctx context.Context, config RunConfig, serviceStack *zBusinessZeropsApiProtocol.GetServiceStackByNameResponseDto) (*zBusinessZeropsApiProtocol.PostAppVersionResponseDto, error) {
appVersionResponse, err := h.apiGrpcClient.PostAppVersion(ctx, &zBusinessZeropsApiProtocol.PostAppVersionRequest{
ServiceStackId: serviceStack.GetId(),
Name: func() *business.StringNull {
Name: func() *zBusinessZeropsApiProtocol.StringNull {
if config.VersionName != "" {
return &business.StringNull{
return &zBusinessZeropsApiProtocol.StringNull{
Value: config.VersionName,
Valid: true,
}
}
return &business.StringNull{}
return &zBusinessZeropsApiProtocol.StringNull{}
}(),
})
if err := proto.BusinessError(appVersionResponse, err); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions src/cliAction/buildDeploy/handler_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/zerops-io/zcli/src/constants"
"github.com/zerops-io/zcli/src/i18n"
"github.com/zerops-io/zcli/src/proto"
"github.com/zerops-io/zcli/src/proto/business"
"github.com/zerops-io/zcli/src/proto/zBusinessZeropsApiProtocol"
"github.com/zerops-io/zcli/src/utils/processChecker"
)

Expand Down Expand Up @@ -70,7 +70,7 @@ func (h *Handler) Deploy(ctx context.Context, config RunConfig) error {

fmt.Println(i18n.BuildDeployDeployingStart)

deployResponse, err := h.apiGrpcClient.PutAppVersionDeploy(ctx, &business.PutAppVersionDeployRequest{
deployResponse, err := h.apiGrpcClient.PutAppVersionDeploy(ctx, &zBusinessZeropsApiProtocol.PutAppVersionDeployRequest{
Id: appVersion.GetId(),
ConfigContent: configContent,
})
Expand All @@ -90,7 +90,7 @@ func (h *Handler) Deploy(ctx context.Context, config RunConfig) error {
return nil
}

func getConfigContent(config RunConfig) (*business.StringNull, error) {
func getConfigContent(config RunConfig) (*zBusinessZeropsApiProtocol.StringNull, error) {
workingDir, err := filepath.Abs(config.WorkingDir)
if err != nil {
return nil, err
Expand Down Expand Up @@ -126,7 +126,7 @@ func getConfigContent(config RunConfig) (*business.StringNull, error) {
return nil, err
}

return &business.StringNull{
return &zBusinessZeropsApiProtocol.StringNull{
Value: base64.StdEncoding.EncodeToString(yamlContent),
Valid: true,
}, nil
Expand Down
5 changes: 2 additions & 3 deletions src/cliAction/buildDeploy/handler_packageUpload.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import (
"io"
"net/http"

"github.com/zerops-io/zcli/src/proto/business"

"github.com/zerops-io/zcli/src/i18n"
"github.com/zerops-io/zcli/src/proto/zBusinessZeropsApiProtocol"
"github.com/zerops-io/zcli/src/utils/httpClient"
)

func (h *Handler) packageUpload(appVersion *business.PostAppVersionResponseDto, reader io.Reader) error {
func (h *Handler) packageUpload(appVersion *zBusinessZeropsApiProtocol.PostAppVersionResponseDto, reader io.Reader) error {
fmt.Println(i18n.BuildDeployUploadingPackageStart)

cephResponse, err := h.httpClient.PutStream(appVersion.GetUploadUrl(), reader, httpClient.ContentType("application/gzip"))
Expand Down
6 changes: 3 additions & 3 deletions src/cliAction/buildDeploy/handler_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/zerops-io/zcli/src/constants"
"github.com/zerops-io/zcli/src/i18n"
"github.com/zerops-io/zcli/src/proto"
"github.com/zerops-io/zcli/src/proto/business"
"github.com/zerops-io/zcli/src/proto/zBusinessZeropsApiProtocol"
"github.com/zerops-io/zcli/src/utils/processChecker"
)

Expand Down Expand Up @@ -102,10 +102,10 @@ func (h *Handler) Push(ctx context.Context, config RunConfig) error {

fmt.Println(i18n.BuildDeployDeployingStart)

deployResponse, err := h.apiGrpcClient.PutAppVersionBuildAndDeploy(ctx, &business.PutAppVersionBuildAndDeployRequest{
deployResponse, err := h.apiGrpcClient.PutAppVersionBuildAndDeploy(ctx, &zBusinessZeropsApiProtocol.PutAppVersionBuildAndDeployRequest{
Id: appVersion.GetId(),
BuildConfigContent: base64.StdEncoding.EncodeToString(buildConfigContent),
Source: &business.StringNull{
Source: &zBusinessZeropsApiProtocol.StringNull{
Value: config.SourceName,
Valid: true,
},
Expand Down
4 changes: 2 additions & 2 deletions src/cliAction/importProjectService/dataParse.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package importProjectService
import (
"fmt"

"github.com/zerops-io/zcli/src/proto/business"
"github.com/zerops-io/zcli/src/proto/zBusinessZeropsApiProtocol"
)

// return number of services and process data [](process Id, service name, action name)
func parseServiceData(servicesData []*business.ProjectImportServiceStack) (int, [][]string) {
func parseServiceData(servicesData []*zBusinessZeropsApiProtocol.ProjectImportServiceStack) (int, [][]string) {
var (
serviceNames = make([]string, 0, len(servicesData))
processData [][]string
Expand Down
6 changes: 3 additions & 3 deletions src/cliAction/importProjectService/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package importProjectService

import (
"github.com/zerops-io/zcli/src/constants"
"github.com/zerops-io/zcli/src/proto/business"
"github.com/zerops-io/zcli/src/proto/zBusinessZeropsApiProtocol"
"github.com/zerops-io/zcli/src/utils/httpClient"
"github.com/zerops-io/zcli/src/utils/sdkConfig"
)
Expand All @@ -21,11 +21,11 @@ type RunConfig struct {
type Handler struct {
config Config
httpClient *httpClient.Handler
apiGrpcClient business.ZeropsApiProtocolClient
apiGrpcClient zBusinessZeropsApiProtocol.ZBusinessZeropsApiProtocolClient
sdkConfig sdkConfig.Config
}

func New(config Config, httpClient *httpClient.Handler, apiGrpcClient business.ZeropsApiProtocolClient, sdkConfig sdkConfig.Config) *Handler {
func New(config Config, httpClient *httpClient.Handler, apiGrpcClient zBusinessZeropsApiProtocol.ZBusinessZeropsApiProtocolClient, sdkConfig sdkConfig.Config) *Handler {
return &Handler{
config: config,
httpClient: httpClient,
Expand Down
5 changes: 3 additions & 2 deletions src/cliAction/importProjectService/handler_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
"time"

"github.com/briandowns/spinner"

"github.com/zerops-io/zcli/src/constants"
"github.com/zerops-io/zcli/src/i18n"
"github.com/zerops-io/zcli/src/proto/business"
"github.com/zerops-io/zcli/src/proto/zBusinessZeropsApiProtocol"
"github.com/zerops-io/zcli/src/utils/processChecker"
)

Expand All @@ -21,7 +22,7 @@ func (h *Handler) Import(ctx context.Context, config RunConfig) error {
return err
}

var servicesData []*business.ProjectImportServiceStack
var servicesData []*zBusinessZeropsApiProtocol.ProjectImportServiceStack
isProjectCmd := config.ParentCmd == constants.Project

if isProjectCmd {
Expand Down
6 changes: 3 additions & 3 deletions src/cliAction/importProjectService/handler_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import (
"github.com/zerops-io/zcli/src/constants"
"github.com/zerops-io/zcli/src/i18n"
"github.com/zerops-io/zcli/src/proto"
"github.com/zerops-io/zcli/src/proto/business"
"github.com/zerops-io/zcli/src/proto/zBusinessZeropsApiProtocol"
)

func (h *Handler) sendProjectRequest(ctx context.Context, config RunConfig, yamlContent string) ([]*business.ProjectImportServiceStack, error) {
func (h *Handler) sendProjectRequest(ctx context.Context, config RunConfig, yamlContent string) ([]*zBusinessZeropsApiProtocol.ProjectImportServiceStack, error) {
clientId, err := h.getClientId(ctx, config)
if err != nil {
return nil, err
}

res, err := h.apiGrpcClient.PostProjectImport(ctx, &business.PostProjectImportRequest{
res, err := h.apiGrpcClient.PostProjectImport(ctx, &zBusinessZeropsApiProtocol.PostProjectImportRequest{
ClientId: clientId,
Yaml: yamlContent,
})
Expand Down
6 changes: 3 additions & 3 deletions src/cliAction/importProjectService/handler_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import (
"context"

"github.com/zerops-io/zcli/src/proto"
"github.com/zerops-io/zcli/src/proto/business"
"github.com/zerops-io/zcli/src/proto/zBusinessZeropsApiProtocol"
"github.com/zerops-io/zcli/src/utils/projectService"
)

func (h *Handler) sendServiceRequest(ctx context.Context, config RunConfig, yamlContent string) ([]*business.ProjectImportServiceStack, error) {
func (h *Handler) sendServiceRequest(ctx context.Context, config RunConfig, yamlContent string) ([]*zBusinessZeropsApiProtocol.ProjectImportServiceStack, error) {
projectId, err := projectService.GetProjectId(ctx, h.apiGrpcClient, config.ProjectNameOrId, h.sdkConfig)
if err != nil {
return nil, err
}

res, err := h.apiGrpcClient.PostServiceStackImport(ctx, &business.PostServiceStackImportRequest{
res, err := h.apiGrpcClient.PostServiceStackImport(ctx, &zBusinessZeropsApiProtocol.PostServiceStackImportRequest{
ProjectId: projectId,
Yaml: yamlContent,
})
Expand Down
13 changes: 6 additions & 7 deletions src/cliAction/login/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import (
"fmt"
"net/http"

"github.com/zerops-io/zcli/src/proto"
"github.com/zerops-io/zcli/src/proto/business"
"github.com/zerops-io/zcli/src/proto/daemon"

"github.com/zerops-io/zcli/src/cliStorage"
"github.com/zerops-io/zcli/src/i18n"
"github.com/zerops-io/zcli/src/proto"
"github.com/zerops-io/zcli/src/proto/daemon"
"github.com/zerops-io/zcli/src/proto/zBusinessZeropsApiProtocol"
"github.com/zerops-io/zcli/src/utils/httpClient"
)

Expand All @@ -31,14 +30,14 @@ type Handler struct {
config Config
storage *cliStorage.Handler
httpClient *httpClient.Handler
grpcApiClientFactory *business.Handler
grpcApiClientFactory *zBusinessZeropsApiProtocol.Handler
}

func New(
config Config,
storage *cliStorage.Handler,
httpClient *httpClient.Handler,
grpcApiClientFactory *business.Handler,
grpcApiClientFactory *zBusinessZeropsApiProtocol.Handler,
) *Handler {
return &Handler{
config: config,
Expand Down Expand Up @@ -157,7 +156,7 @@ func (h *Handler) loginWithToken(ctx context.Context, token string) error {
}
defer closeFunc()

resp, err := grpcApiClient.GetUserInfo(ctx, &business.GetUserInfoRequest{})
resp, err := grpcApiClient.GetUserInfo(ctx, &zBusinessZeropsApiProtocol.GetUserInfoRequest{})

if err := proto.BusinessError(resp, err); err != nil {
if proto.IsUnauthenticated(err) {
Expand Down
6 changes: 3 additions & 3 deletions src/cliAction/serviceLogs/handler.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package serviceLogs

import (
"github.com/zerops-io/zcli/src/proto/business"
"github.com/zerops-io/zcli/src/proto/zBusinessZeropsApiProtocol"
"github.com/zerops-io/zcli/src/utils/httpClient"
"github.com/zerops-io/zcli/src/utils/sdkConfig"
)
Expand All @@ -26,11 +26,11 @@ type RunConfig struct {
type Handler struct {
config Config
httpClient *httpClient.Handler
apiGrpcClient business.ZeropsApiProtocolClient
apiGrpcClient zBusinessZeropsApiProtocol.ZBusinessZeropsApiProtocolClient
sdkConfig sdkConfig.Config
}

func New(config Config, httpClient *httpClient.Handler, apiGrpcClient business.ZeropsApiProtocolClient, sdkConfig sdkConfig.Config) *Handler {
func New(config Config, httpClient *httpClient.Handler, apiGrpcClient zBusinessZeropsApiProtocol.ZBusinessZeropsApiProtocolClient, sdkConfig sdkConfig.Config) *Handler {
return &Handler{
config: config,
httpClient: httpClient,
Expand Down
6 changes: 3 additions & 3 deletions src/cliAction/startStopDelete/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"

"github.com/zerops-io/zcli/src/constants"
"github.com/zerops-io/zcli/src/proto/business"
"github.com/zerops-io/zcli/src/proto/zBusinessZeropsApiProtocol"
"github.com/zerops-io/zcli/src/utils/httpClient"
"github.com/zerops-io/zcli/src/utils/sdkConfig"
)
Expand Down Expand Up @@ -36,11 +36,11 @@ func (c *RunConfig) getCmdProps() (string, string, Method) {
type Handler struct {
config Config
httpClient *httpClient.Handler
apiGrpcClient business.ZeropsApiProtocolClient
apiGrpcClient zBusinessZeropsApiProtocol.ZBusinessZeropsApiProtocolClient
sdkConfig sdkConfig.Config
}

func New(config Config, httpClient *httpClient.Handler, apiGrpcClient business.ZeropsApiProtocolClient, sdkConfig sdkConfig.Config) *Handler {
func New(config Config, httpClient *httpClient.Handler, apiGrpcClient zBusinessZeropsApiProtocol.ZBusinessZeropsApiProtocolClient, sdkConfig sdkConfig.Config) *Handler {
return &Handler{
config: config,
httpClient: httpClient,
Expand Down
8 changes: 4 additions & 4 deletions src/cliAction/startStopDelete/handler_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"context"

"github.com/zerops-io/zcli/src/proto"
"github.com/zerops-io/zcli/src/proto/business"
"github.com/zerops-io/zcli/src/proto/zBusinessZeropsApiProtocol"
)

func (h *Handler) ProjectStart(ctx context.Context, projectId string, _ string) (string, error) {
startProjectResponse, err := h.apiGrpcClient.PutProjectStart(ctx, &business.PutProjectStartRequest{
startProjectResponse, err := h.apiGrpcClient.PutProjectStart(ctx, &zBusinessZeropsApiProtocol.PutProjectStartRequest{
Id: projectId,
})
if err := proto.BusinessError(startProjectResponse, err); err != nil {
Expand All @@ -19,7 +19,7 @@ func (h *Handler) ProjectStart(ctx context.Context, projectId string, _ string)
}

func (h *Handler) ProjectStop(ctx context.Context, projectId string, _ string) (string, error) {
stopProjectResponse, err := h.apiGrpcClient.PutProjectStop(ctx, &business.PutProjectStopRequest{
stopProjectResponse, err := h.apiGrpcClient.PutProjectStop(ctx, &zBusinessZeropsApiProtocol.PutProjectStopRequest{
Id: projectId,
})
if err := proto.BusinessError(stopProjectResponse, err); err != nil {
Expand All @@ -30,7 +30,7 @@ func (h *Handler) ProjectStop(ctx context.Context, projectId string, _ string) (
}

func (h *Handler) ProjectDelete(ctx context.Context, projectId string, _ string) (string, error) {
deleteProjectResponse, err := h.apiGrpcClient.DeleteProject(ctx, &business.DeleteProjectRequest{
deleteProjectResponse, err := h.apiGrpcClient.DeleteProject(ctx, &zBusinessZeropsApiProtocol.DeleteProjectRequest{
Id: projectId,
})

Expand Down
Loading

0 comments on commit 726559d

Please sign in to comment.