Skip to content

Commit

Permalink
Feat: Add describe service
Browse files Browse the repository at this point in the history
  • Loading branch information
umanggoyald11 committed Sep 17, 2024
1 parent 199fe9b commit edbe788
Show file tree
Hide file tree
Showing 9 changed files with 620 additions and 200 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/iancoleman/orderedmap v0.3.0
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,8 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO
github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc=
github.com/hashicorp/memberlist v0.5.0/go.mod h1:yvyXLpo0QaGE59Y7hDTsTzDD25JYBZ4mHgHUZ8lrOI0=
github.com/hashicorp/serf v0.10.1/go.mod h1:yL2t6BqATOLGc5HF7qbFkTfXoPIY0WZdWHfEvMqbG+4=
github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc=
github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
Expand Down
15 changes: 15 additions & 0 deletions internal/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
serviceDto "github.com/dream11/odin/proto/gen/go/dream11/od/dto/v1"
serviceProto "github.com/dream11/odin/proto/gen/go/dream11/od/service/v1"
log "github.com/sirupsen/logrus"

)

// Service performs operation on service like deploy. undeploy
Expand Down Expand Up @@ -266,3 +267,17 @@ func (e *Service) ConvertToDeployServiceSetRequest(serviceSet *serviceDto.Servic
Services: services,
}
}

func (e *Service) DescribeService(ctx *context.Context, request *serviceProto.DescribeServiceRequest) (*serviceProto.DescribeServiceResponse, error) {
conn, requestCtx, err := grpcClient(ctx)
if err != nil {
return nil, err
}
client := serviceProto.NewServiceServiceClient(conn)
response, err := client.DescribeService(*requestCtx, request)
if err != nil {
return nil, err
}

return response, nil
}
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
_ "github.com/dream11/odin/cmd/undeploy"
_ "github.com/dream11/odin/cmd/update"
_ "github.com/dream11/odin/internal/ui"
_ "github.com/dream11/odin/cmd/describe"

Check failure on line 18 in main.go

View workflow job for this annotation

GitHub Actions / lint

no required module provides package github.com/dream11/odin/cmd/describe; to add it:
)

func main() {
Expand Down
13 changes: 13 additions & 0 deletions proto/dream11/od/dto/v1/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";
package dream11.od.dto.v1;

import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";

option go_package = "github.com/dream11/odin/proto/gen/go/dream11/od/dto/v1";

Expand Down Expand Up @@ -63,3 +64,15 @@ message AddComponentRequestOptions {
message RemoveComponentRequestOptions {
string component_name = 1;
}

message Service {
optional string name = 1;
optional string version = 2;
optional google.protobuf.Timestamp created_at = 3;
optional google.protobuf.Timestamp updated_at = 4;
optional string created_by = 5;
optional string updated_by = 6;
optional google.protobuf.Struct labels = 7;
optional google.protobuf.Struct service_definition = 8;
repeated google.protobuf.Struct provisioning_config_files = 9;
}
11 changes: 11 additions & 0 deletions proto/dream11/od/service/v1/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ service ServiceService {
rpc OperateService(OperateServiceRequest) returns (stream OperateServiceResponse) {}
rpc UndeployService(UndeployServiceRequest) returns (stream UndeployServiceResponse) {}
rpc ListService(ListServiceRequest) returns (ListServiceResponse) {}
rpc DescribeService(DescribeServiceRequest) returns (DescribeServiceResponse) {}
}

message DeployServiceRequest {
Expand Down Expand Up @@ -118,3 +119,13 @@ message ListServiceRequest {
string team = 3;
string label = 4;
}

message DescribeServiceRequest {
string service_name = 1;
string version = 2;
map<string, string> params = 4;
}

message DescribeServiceResponse {
dream11.od.dto.v1.Service service = 1;
}
395 changes: 283 additions & 112 deletions proto/gen/go/dream11/od/dto/v1/service.pb.go

Large diffs are not rendered by default.

345 changes: 257 additions & 88 deletions proto/gen/go/dream11/od/service/v1/service.pb.go

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions proto/gen/go/dream11/od/service/v1/service_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit edbe788

Please sign in to comment.