diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 06cb2e1..6566607 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -2,7 +2,7 @@ name: CI on: push: - branches: ["main"] + branches: ["main", "eedorenko/*"] workflow_dispatch: env: @@ -57,6 +57,11 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: '1.19' - name: Install Helmify run: | diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 24c62db..0c2ebce 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -126,8 +126,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-go@v4 + - name: Install Go + uses: actions/setup-go@v2 with: + go-version: '1.19' cache: false - name: golangci-lint uses: golangci/golangci-lint-action@v3 diff --git a/go.mod b/go.mod index 67a3ce2..ecf74d1 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/microsoft/kalypso-observability-hub/storage v0.0.0 github.com/onsi/ginkgo/v2 v2.9.5 github.com/onsi/gomega v1.27.7 + k8s.io/api v0.27.3 k8s.io/apimachinery v0.27.3 k8s.io/client-go v0.27.3 sigs.k8s.io/controller-runtime v0.15.0 @@ -75,11 +76,10 @@ require ( google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect google.golang.org/grpc v1.56.3 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/protobuf v1.34.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/api v0.27.3 // indirect k8s.io/apiextensions-apiserver v0.27.3 // indirect k8s.io/component-base v0.27.3 // indirect k8s.io/klog/v2 v2.90.1 // indirect diff --git a/go.sum b/go.sum index c395f7d..458becc 100644 --- a/go.sum +++ b/go.sum @@ -269,8 +269,8 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/storage/api/grpc/client/client.go b/storage/api/grpc/client/client.go index adb1459..3bf300c 100644 --- a/storage/api/grpc/client/client.go +++ b/storage/api/grpc/client/client.go @@ -23,6 +23,7 @@ type ObservabilityStorageGrpcClient interface { UpdateReconciler(ctx context.Context, in *pb.Reconciler) (*pb.Reconciler, error) UpdateDeployment(ctx context.Context, in *pb.Deployment) (*pb.Deployment, error) GetDeploymentTarget(ctx context.Context, in *pb.DeploymentTargetSearch) (*pb.DeploymentTarget, error) + GetDeploymentState(ctx context.Context, in *pb.DeploymentStateRequest) (*pb.DeploymentState, error) } type observabilityStorageGrpcClient struct { @@ -210,3 +211,19 @@ func (c *observabilityStorageGrpcClient) GetDeploymentTarget(ctx context.Context } return dt, nil } + +// GetDeploymentState +func (c *observabilityStorageGrpcClient) GetDeploymentState(ctx context.Context, in *pb.DeploymentStateRequest) (*pb.DeploymentState, error) { + conn, err := c.getConnection() + if err != nil { + return nil, err + } + defer conn.Close() + client := pb.NewStorageApiClient(conn) + + ds, err := client.GetDeploymentState(ctx, in) + if err != nil { + return nil, err + } + return ds, nil +} diff --git a/storage/api/grpc/client/client_test.go b/storage/api/grpc/client/client_test.go index af66a19..8437956 100644 --- a/storage/api/grpc/client/client_test.go +++ b/storage/api/grpc/client/client_test.go @@ -162,3 +162,19 @@ func TestUpdateDeployment(t *testing.T) { return } } + +// Test GetDeploymentState +func TestGetDeploymentState(t *testing.T) { + client := NewObservabilityStorageGrpcClient(*serverAddr) + deployment_state, err := client.GetDeploymentState(context.Background(), &pb.DeploymentStateRequest{ + ManifestsEndpoint: "https://github.com/Org/data-ingestion/dev%", + CommitId: "sha1:a97f94d3f3ede63d08d58ae4cf9f3262d7679c4f", + }) + // Print the deployment state + t.Logf("DeploymentState: %v", *deployment_state) + + if err != nil { + t.Errorf("GetDeploymentState() error = %v", err) + return + } +} diff --git a/storage/api/grpc/proto/storage.pb.go b/storage/api/grpc/proto/storage.pb.go index e0ecb71..3ff1a0c 100644 --- a/storage/api/grpc/proto/storage.pb.go +++ b/storage/api/grpc/proto/storage.pb.go @@ -897,6 +897,211 @@ func (x *DeploymentTargetSearch) GetEnvironmentName() string { return "" } +type DeploymentStateRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ManifestsEndpoint string `protobuf:"bytes,1,opt,name=manifests_endpoint,json=manifestsEndpoint,proto3" json:"manifests_endpoint,omitempty"` + CommitId string `protobuf:"bytes,2,opt,name=commit_id,json=commitId,proto3" json:"commit_id,omitempty"` +} + +func (x *DeploymentStateRequest) Reset() { + *x = DeploymentStateRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_storage_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeploymentStateRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeploymentStateRequest) ProtoMessage() {} + +func (x *DeploymentStateRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_storage_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeploymentStateRequest.ProtoReflect.Descriptor instead. +func (*DeploymentStateRequest) Descriptor() ([]byte, []int) { + return file_proto_storage_proto_rawDescGZIP(), []int{11} +} + +func (x *DeploymentStateRequest) GetManifestsEndpoint() string { + if x != nil { + return x.ManifestsEndpoint + } + return "" +} + +func (x *DeploymentStateRequest) GetCommitId() string { + if x != nil { + return x.CommitId + } + return "" +} + +type DeploymentState struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TotalSubscribers int32 `protobuf:"varint,1,opt,name=total_subscribers,json=totalSubscribers,proto3" json:"total_subscribers"` + TotalSucceededSubscribers int32 `protobuf:"varint,2,opt,name=total_succeeded_subscribers,json=totalSucceededSubscribers,proto3" json:"total_succeeded_subscribers,omitempty"` + TotalFailedSubscribers int32 `protobuf:"varint,3,opt,name=total_failed_subscribers,json=totalFailedSubscribers,proto3" json:"total_failed_subscribers,omitempty"` + TotalInProgressSubscribers int32 `protobuf:"varint,4,opt,name=total_in_progress_subscribers,json=totalInProgressSubscribers,proto3" json:"total_in_progress_subscribers,omitempty"` + SucceededSubscribers []*Subscriber `protobuf:"bytes,5,rep,name=succeeded_subscribers,json=succeededSubscribers,proto3" json:"succeeded_subscribers,omitempty"` + FailedSubscribers []*Subscriber `protobuf:"bytes,6,rep,name=failed_subscribers,json=failedSubscribers,proto3" json:"failed_subscribers,omitempty"` + InProgressSubscribers []*Subscriber `protobuf:"bytes,7,rep,name=in_progress_subscribers,json=inProgressSubscribers,proto3" json:"in_progress_subscribers,omitempty"` +} + +func (x *DeploymentState) Reset() { + *x = DeploymentState{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_storage_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeploymentState) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeploymentState) ProtoMessage() {} + +func (x *DeploymentState) ProtoReflect() protoreflect.Message { + mi := &file_proto_storage_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeploymentState.ProtoReflect.Descriptor instead. +func (*DeploymentState) Descriptor() ([]byte, []int) { + return file_proto_storage_proto_rawDescGZIP(), []int{12} +} + +func (x *DeploymentState) GetTotalSubscribers() int32 { + if x != nil { + return x.TotalSubscribers + } + return 0 +} + +func (x *DeploymentState) GetTotalSucceededSubscribers() int32 { + if x != nil { + return x.TotalSucceededSubscribers + } + return 0 +} + +func (x *DeploymentState) GetTotalFailedSubscribers() int32 { + if x != nil { + return x.TotalFailedSubscribers + } + return 0 +} + +func (x *DeploymentState) GetTotalInProgressSubscribers() int32 { + if x != nil { + return x.TotalInProgressSubscribers + } + return 0 +} + +func (x *DeploymentState) GetSucceededSubscribers() []*Subscriber { + if x != nil { + return x.SucceededSubscribers + } + return nil +} + +func (x *DeploymentState) GetFailedSubscribers() []*Subscriber { + if x != nil { + return x.FailedSubscribers + } + return nil +} + +func (x *DeploymentState) GetInProgressSubscribers() []*Subscriber { + if x != nil { + return x.InProgressSubscribers + } + return nil +} + +type Subscriber struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + StatusMessage string `protobuf:"bytes,2,opt,name=status_message,json=statusMessage,proto3" json:"status_message,omitempty"` +} + +func (x *Subscriber) Reset() { + *x = Subscriber{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_storage_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Subscriber) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Subscriber) ProtoMessage() {} + +func (x *Subscriber) ProtoReflect() protoreflect.Message { + mi := &file_proto_storage_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Subscriber.ProtoReflect.Descriptor instead. +func (*Subscriber) Descriptor() ([]byte, []int) { + return file_proto_storage_proto_rawDescGZIP(), []int{13} +} + +func (x *Subscriber) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Subscriber) GetStatusMessage() string { + if x != nil { + return x.StatusMessage + } + return "" +} + var File_proto_storage_proto protoreflect.FileDescriptor var file_proto_storage_proto_rawDesc = []byte{ @@ -1023,59 +1228,104 @@ var file_proto_storage_proto_rawDesc = []byte{ 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x77, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x29, 0x0a, 0x10, 0x65, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x65, - 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x32, 0xdf, - 0x05, 0x0a, 0x0a, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x41, 0x70, 0x69, 0x12, 0x37, 0x0a, - 0x0f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, - 0x12, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, - 0x63, 0x65, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, - 0x70, 0x61, 0x63, 0x65, 0x22, 0x00, 0x12, 0x3d, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, - 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x22, 0x00, 0x12, 0x34, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, - 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, - 0x57, 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, 0x64, 0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x00, 0x12, 0x3d, 0x0a, 0x11, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, - 0x12, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, - 0x6d, 0x65, 0x6e, 0x74, 0x1a, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6e, 0x76, - 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x00, 0x12, 0x4c, 0x0a, 0x16, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x54, 0x61, - 0x72, 0x67, 0x65, 0x74, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x70, - 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x1a, 0x17, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, - 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0x00, 0x12, 0x49, 0x0a, 0x15, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, 0x64, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x6c, 0x6f, - 0x61, 0x64, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x1a, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, 0x64, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x22, 0x00, 0x12, 0x58, 0x0a, 0x1a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, 0x65, 0x70, - 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, - 0x74, 0x12, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, - 0x6d, 0x65, 0x6e, 0x74, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x1a, 0x1b, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, - 0x74, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x00, 0x12, 0x28, 0x0a, - 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x0b, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x63, 0x69, 0x6c, 0x65, 0x72, 0x12, 0x11, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x63, 0x69, 0x6c, 0x65, 0x72, 0x1a, 0x11, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x63, 0x69, 0x6c, 0x65, - 0x72, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, 0x65, 0x70, - 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, - 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x1a, 0x11, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x00, 0x12, - 0x4f, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, - 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, - 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x53, - 0x65, 0x61, 0x72, 0x63, 0x68, 0x1a, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, - 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0x00, - 0x42, 0x47, 0x5a, 0x45, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6d, - 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x2f, 0x6b, 0x61, 0x6c, 0x79, 0x70, 0x73, 0x6f, - 0x2d, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2d, 0x68, - 0x75, 0x62, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, - 0x72, 0x70, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x64, + 0x0a, 0x16, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, + 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2d, 0x0a, 0x12, 0x6d, 0x61, 0x6e, 0x69, + 0x66, 0x65, 0x73, 0x74, 0x73, 0x5f, 0x65, 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x73, 0x45, + 0x6e, 0x64, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x69, + 0x74, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x6d, + 0x69, 0x74, 0x49, 0x64, 0x22, 0xd0, 0x03, 0x0a, 0x0f, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x2b, 0x0a, 0x11, 0x74, 0x6f, 0x74, 0x61, + 0x6c, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x10, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, + 0x69, 0x62, 0x65, 0x72, 0x73, 0x12, 0x3e, 0x0a, 0x1b, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x73, + 0x75, 0x63, 0x63, 0x65, 0x65, 0x64, 0x65, 0x64, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, + 0x62, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x19, 0x74, 0x6f, 0x74, 0x61, + 0x6c, 0x53, 0x75, 0x63, 0x63, 0x65, 0x65, 0x64, 0x65, 0x64, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, + 0x69, 0x62, 0x65, 0x72, 0x73, 0x12, 0x38, 0x0a, 0x18, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x66, + 0x61, 0x69, 0x6c, 0x65, 0x64, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, + 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x16, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x46, 0x61, + 0x69, 0x6c, 0x65, 0x64, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x73, 0x12, + 0x41, 0x0a, 0x1d, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x69, 0x6e, 0x5f, 0x70, 0x72, 0x6f, 0x67, + 0x72, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x73, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x1a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x49, 0x6e, 0x50, + 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, + 0x72, 0x73, 0x12, 0x46, 0x0a, 0x15, 0x73, 0x75, 0x63, 0x63, 0x65, 0x65, 0x64, 0x65, 0x64, 0x5f, + 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, + 0x69, 0x62, 0x65, 0x72, 0x52, 0x14, 0x73, 0x75, 0x63, 0x63, 0x65, 0x65, 0x64, 0x65, 0x64, 0x53, + 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x73, 0x12, 0x40, 0x0a, 0x12, 0x66, 0x61, + 0x69, 0x6c, 0x65, 0x64, 0x5f, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x73, + 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, + 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x52, 0x11, 0x66, 0x61, 0x69, 0x6c, 0x65, + 0x64, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x73, 0x12, 0x49, 0x0a, 0x17, + 0x69, 0x6e, 0x5f, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x75, 0x62, 0x73, + 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, + 0x52, 0x15, 0x69, 0x6e, 0x50, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x53, 0x75, 0x62, 0x73, + 0x63, 0x72, 0x69, 0x62, 0x65, 0x72, 0x73, 0x22, 0x47, 0x0a, 0x0a, 0x53, 0x75, 0x62, 0x73, 0x63, + 0x72, 0x69, 0x62, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x32, 0xae, 0x06, 0x0a, 0x0a, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x41, 0x70, 0x69, 0x12, + 0x37, 0x0a, 0x0f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x73, 0x70, 0x61, + 0x63, 0x65, 0x12, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x73, + 0x70, 0x61, 0x63, 0x65, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x57, 0x6f, 0x72, + 0x6b, 0x73, 0x70, 0x61, 0x63, 0x65, 0x22, 0x00, 0x12, 0x3d, 0x0a, 0x11, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x1a, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x70, 0x70, 0x6c, 0x69, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x00, 0x12, 0x34, 0x0a, 0x0e, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, 0x64, 0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x00, 0x12, 0x3d, 0x0a, + 0x11, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x45, 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, + 0x6e, 0x74, 0x12, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6e, 0x76, 0x69, 0x72, + 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x1a, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, + 0x6e, 0x76, 0x69, 0x72, 0x6f, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x00, 0x12, 0x4c, 0x0a, 0x16, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, + 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, + 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x1a, + 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, + 0x6e, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0x00, 0x12, 0x49, 0x0a, 0x15, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x57, 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, 0x64, 0x56, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x57, 0x6f, 0x72, 0x6b, + 0x6c, 0x6f, 0x61, 0x64, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x1a, 0x16, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x57, 0x6f, 0x72, 0x6b, 0x6c, 0x6f, 0x61, 0x64, 0x56, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x22, 0x00, 0x12, 0x58, 0x0a, 0x1a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, + 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, + 0x65, 0x6e, 0x74, 0x12, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x70, 0x6c, + 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, + 0x1a, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x41, 0x73, 0x73, 0x69, 0x67, 0x6e, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x00, 0x12, + 0x28, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x0b, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x48, 0x6f, 0x73, 0x74, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x10, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x63, 0x69, 0x6c, 0x65, 0x72, 0x12, 0x11, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x63, 0x69, 0x6c, 0x65, 0x72, + 0x1a, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x6e, 0x63, 0x69, + 0x6c, 0x65, 0x72, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x44, + 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x1a, 0x11, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x22, + 0x00, 0x12, 0x4f, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, + 0x6e, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, + 0x74, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x1a, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, + 0x22, 0x00, 0x12, 0x4d, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x74, 0x61, 0x74, 0x65, 0x22, + 0x00, 0x42, 0x47, 0x5a, 0x45, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x2f, 0x6b, 0x61, 0x6c, 0x79, 0x70, 0x73, + 0x6f, 0x2d, 0x6f, 0x62, 0x73, 0x65, 0x72, 0x76, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2d, + 0x68, 0x75, 0x62, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x67, 0x72, 0x70, 0x63, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -1090,7 +1340,7 @@ func file_proto_storage_proto_rawDescGZIP() []byte { return file_proto_storage_proto_rawDescData } -var file_proto_storage_proto_msgTypes = make([]protoimpl.MessageInfo, 11) +var file_proto_storage_proto_msgTypes = make([]protoimpl.MessageInfo, 14) var file_proto_storage_proto_goTypes = []interface{}{ (*Workspace)(nil), // 0: proto.Workspace (*Application)(nil), // 1: proto.Application @@ -1103,35 +1353,43 @@ var file_proto_storage_proto_goTypes = []interface{}{ (*Reconciler)(nil), // 8: proto.Reconciler (*Deployment)(nil), // 9: proto.Deployment (*DeploymentTargetSearch)(nil), // 10: proto.DeploymentTargetSearch + (*DeploymentStateRequest)(nil), // 11: proto.DeploymentStateRequest + (*DeploymentState)(nil), // 12: proto.DeploymentState + (*Subscriber)(nil), // 13: proto.Subscriber } var file_proto_storage_proto_depIdxs = []int32{ - 0, // 0: proto.StorageApi.UpdateWorkspace:input_type -> proto.Workspace - 1, // 1: proto.StorageApi.UpdateApplication:input_type -> proto.Application - 2, // 2: proto.StorageApi.UpdateWorkload:input_type -> proto.Workload - 3, // 3: proto.StorageApi.UpdateEnvironment:input_type -> proto.Environment - 4, // 4: proto.StorageApi.UpdateDeploymentTarget:input_type -> proto.DeploymentTarget - 5, // 5: proto.StorageApi.UpdateWorkloadVersion:input_type -> proto.WorkloadVersion - 6, // 6: proto.StorageApi.UpdateDeploymentAssignment:input_type -> proto.DeploymentAssignment - 7, // 7: proto.StorageApi.UpdateHost:input_type -> proto.Host - 8, // 8: proto.StorageApi.UpdateReconciler:input_type -> proto.Reconciler - 9, // 9: proto.StorageApi.UpdateDeployment:input_type -> proto.Deployment - 10, // 10: proto.StorageApi.GetDeploymentTarget:input_type -> proto.DeploymentTargetSearch - 0, // 11: proto.StorageApi.UpdateWorkspace:output_type -> proto.Workspace - 1, // 12: proto.StorageApi.UpdateApplication:output_type -> proto.Application - 2, // 13: proto.StorageApi.UpdateWorkload:output_type -> proto.Workload - 3, // 14: proto.StorageApi.UpdateEnvironment:output_type -> proto.Environment - 4, // 15: proto.StorageApi.UpdateDeploymentTarget:output_type -> proto.DeploymentTarget - 5, // 16: proto.StorageApi.UpdateWorkloadVersion:output_type -> proto.WorkloadVersion - 6, // 17: proto.StorageApi.UpdateDeploymentAssignment:output_type -> proto.DeploymentAssignment - 7, // 18: proto.StorageApi.UpdateHost:output_type -> proto.Host - 8, // 19: proto.StorageApi.UpdateReconciler:output_type -> proto.Reconciler - 9, // 20: proto.StorageApi.UpdateDeployment:output_type -> proto.Deployment - 4, // 21: proto.StorageApi.GetDeploymentTarget:output_type -> proto.DeploymentTarget - 11, // [11:22] is the sub-list for method output_type - 0, // [0:11] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 13, // 0: proto.DeploymentState.succeeded_subscribers:type_name -> proto.Subscriber + 13, // 1: proto.DeploymentState.failed_subscribers:type_name -> proto.Subscriber + 13, // 2: proto.DeploymentState.in_progress_subscribers:type_name -> proto.Subscriber + 0, // 3: proto.StorageApi.UpdateWorkspace:input_type -> proto.Workspace + 1, // 4: proto.StorageApi.UpdateApplication:input_type -> proto.Application + 2, // 5: proto.StorageApi.UpdateWorkload:input_type -> proto.Workload + 3, // 6: proto.StorageApi.UpdateEnvironment:input_type -> proto.Environment + 4, // 7: proto.StorageApi.UpdateDeploymentTarget:input_type -> proto.DeploymentTarget + 5, // 8: proto.StorageApi.UpdateWorkloadVersion:input_type -> proto.WorkloadVersion + 6, // 9: proto.StorageApi.UpdateDeploymentAssignment:input_type -> proto.DeploymentAssignment + 7, // 10: proto.StorageApi.UpdateHost:input_type -> proto.Host + 8, // 11: proto.StorageApi.UpdateReconciler:input_type -> proto.Reconciler + 9, // 12: proto.StorageApi.UpdateDeployment:input_type -> proto.Deployment + 10, // 13: proto.StorageApi.GetDeploymentTarget:input_type -> proto.DeploymentTargetSearch + 11, // 14: proto.StorageApi.GetDeploymentState:input_type -> proto.DeploymentStateRequest + 0, // 15: proto.StorageApi.UpdateWorkspace:output_type -> proto.Workspace + 1, // 16: proto.StorageApi.UpdateApplication:output_type -> proto.Application + 2, // 17: proto.StorageApi.UpdateWorkload:output_type -> proto.Workload + 3, // 18: proto.StorageApi.UpdateEnvironment:output_type -> proto.Environment + 4, // 19: proto.StorageApi.UpdateDeploymentTarget:output_type -> proto.DeploymentTarget + 5, // 20: proto.StorageApi.UpdateWorkloadVersion:output_type -> proto.WorkloadVersion + 6, // 21: proto.StorageApi.UpdateDeploymentAssignment:output_type -> proto.DeploymentAssignment + 7, // 22: proto.StorageApi.UpdateHost:output_type -> proto.Host + 8, // 23: proto.StorageApi.UpdateReconciler:output_type -> proto.Reconciler + 9, // 24: proto.StorageApi.UpdateDeployment:output_type -> proto.Deployment + 4, // 25: proto.StorageApi.GetDeploymentTarget:output_type -> proto.DeploymentTarget + 12, // 26: proto.StorageApi.GetDeploymentState:output_type -> proto.DeploymentState + 15, // [15:27] is the sub-list for method output_type + 3, // [3:15] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_proto_storage_proto_init() } @@ -1272,6 +1530,42 @@ func file_proto_storage_proto_init() { return nil } } + file_proto_storage_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeploymentStateRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_storage_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeploymentState); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_proto_storage_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Subscriber); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -1279,7 +1573,7 @@ func file_proto_storage_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_proto_storage_proto_rawDesc, NumEnums: 0, - NumMessages: 11, + NumMessages: 14, NumExtensions: 0, NumServices: 1, }, diff --git a/storage/api/grpc/proto/storage.proto b/storage/api/grpc/proto/storage.proto index 0088645..5206ff4 100644 --- a/storage/api/grpc/proto/storage.proto +++ b/storage/api/grpc/proto/storage.proto @@ -93,6 +93,25 @@ message DeploymentTargetSearch { string environment_name = 5; } +message DeploymentStateRequest { + string manifests_endpoint = 1; + string commit_id = 2; +} + +message DeploymentState { + int32 total_subscribers = 1; + int32 total_succeeded_subscribers = 2; + int32 total_failed_subscribers = 3; + int32 total_in_progress_subscribers = 4; + repeated Subscriber succeeded_subscribers = 5; + repeated Subscriber failed_subscribers = 6; + repeated Subscriber in_progress_subscribers = 7; +} + +message Subscriber { + string name = 1; + string status_message = 2; +} service StorageApi { rpc UpdateWorkspace(Workspace) returns (Workspace) {} @@ -106,4 +125,5 @@ service StorageApi { rpc UpdateReconciler(Reconciler) returns (Reconciler) {} rpc UpdateDeployment(Deployment) returns (Deployment) {} rpc GetDeploymentTarget(DeploymentTargetSearch) returns (DeploymentTarget) {} + rpc GetDeploymentState(DeploymentStateRequest) returns (DeploymentState) {} } \ No newline at end of file diff --git a/storage/api/grpc/proto/storage_grpc.pb.go b/storage/api/grpc/proto/storage_grpc.pb.go index 0784e04..5ae2cb9 100644 --- a/storage/api/grpc/proto/storage_grpc.pb.go +++ b/storage/api/grpc/proto/storage_grpc.pb.go @@ -33,6 +33,7 @@ type StorageApiClient interface { UpdateReconciler(ctx context.Context, in *Reconciler, opts ...grpc.CallOption) (*Reconciler, error) UpdateDeployment(ctx context.Context, in *Deployment, opts ...grpc.CallOption) (*Deployment, error) GetDeploymentTarget(ctx context.Context, in *DeploymentTargetSearch, opts ...grpc.CallOption) (*DeploymentTarget, error) + GetDeploymentState(ctx context.Context, in *DeploymentStateRequest, opts ...grpc.CallOption) (*DeploymentState, error) } type storageApiClient struct { @@ -142,6 +143,15 @@ func (c *storageApiClient) GetDeploymentTarget(ctx context.Context, in *Deployme return out, nil } +func (c *storageApiClient) GetDeploymentState(ctx context.Context, in *DeploymentStateRequest, opts ...grpc.CallOption) (*DeploymentState, error) { + out := new(DeploymentState) + err := c.cc.Invoke(ctx, "/proto.StorageApi/GetDeploymentState", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // StorageApiServer is the server API for StorageApi service. // All implementations must embed UnimplementedStorageApiServer // for forward compatibility @@ -157,6 +167,7 @@ type StorageApiServer interface { UpdateReconciler(context.Context, *Reconciler) (*Reconciler, error) UpdateDeployment(context.Context, *Deployment) (*Deployment, error) GetDeploymentTarget(context.Context, *DeploymentTargetSearch) (*DeploymentTarget, error) + GetDeploymentState(context.Context, *DeploymentStateRequest) (*DeploymentState, error) mustEmbedUnimplementedStorageApiServer() } @@ -197,6 +208,9 @@ func (UnimplementedStorageApiServer) UpdateDeployment(context.Context, *Deployme func (UnimplementedStorageApiServer) GetDeploymentTarget(context.Context, *DeploymentTargetSearch) (*DeploymentTarget, error) { return nil, status.Errorf(codes.Unimplemented, "method GetDeploymentTarget not implemented") } +func (UnimplementedStorageApiServer) GetDeploymentState(context.Context, *DeploymentStateRequest) (*DeploymentState, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetDeploymentState not implemented") +} func (UnimplementedStorageApiServer) mustEmbedUnimplementedStorageApiServer() {} // UnsafeStorageApiServer may be embedded to opt out of forward compatibility for this service. @@ -408,6 +422,24 @@ func _StorageApi_GetDeploymentTarget_Handler(srv interface{}, ctx context.Contex return interceptor(ctx, in, info, handler) } +func _StorageApi_GetDeploymentState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeploymentStateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(StorageApiServer).GetDeploymentState(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.StorageApi/GetDeploymentState", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(StorageApiServer).GetDeploymentState(ctx, req.(*DeploymentStateRequest)) + } + return interceptor(ctx, in, info, handler) +} + // StorageApi_ServiceDesc is the grpc.ServiceDesc for StorageApi service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -459,6 +491,10 @@ var StorageApi_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetDeploymentTarget", Handler: _StorageApi_GetDeploymentTarget_Handler, }, + { + MethodName: "GetDeploymentState", + Handler: _StorageApi_GetDeploymentState_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "proto/storage.proto", diff --git a/storage/api/grpc/server/server.go b/storage/api/grpc/server/server.go index 418fbd3..fd708e6 100644 --- a/storage/api/grpc/server/server.go +++ b/storage/api/grpc/server/server.go @@ -5,7 +5,7 @@ import ( "flag" "fmt" "log" - "net" + "net/http" "os" "strconv" @@ -13,6 +13,9 @@ import ( db "github.com/microsoft/kalypso-observability-hub/storage/postgres" "google.golang.org/grpc" + "github.com/gin-gonic/gin" + "golang.org/x/net/http2" + "golang.org/x/net/http2/h2c" "google.golang.org/grpc/health" "google.golang.org/grpc/health/grpc_health_v1" ) @@ -38,6 +41,8 @@ type storageApiServer struct { // make sure that the server implements the interface var _ pb.StorageApiServer = (*storageApiServer)(nil) +var server *storageApiServer + func (s *storageApiServer) UpdateWorkspace(ctx context.Context, workspace *pb.Workspace) (*pb.Workspace, error) { log.Printf("Received Workspace: %v", workspace) @@ -360,6 +365,60 @@ func (s *storageApiServer) GetDeploymentTarget(ctx context.Context, deploymentTa }, nil } +// Get DeploymentState +func (s *storageApiServer) GetDeploymentState(ctx context.Context, deploymentStateRequest *pb.DeploymentStateRequest) (*pb.DeploymentState, error) { + log.Printf("Received DeploymentStateRequest: %v", deploymentStateRequest) + + deployment_state := &pb.DeploymentState{ + TotalSubscribers: 0, + TotalSucceededSubscribers: 0, + TotalFailedSubscribers: 0, + TotalInProgressSubscribers: 0, + SucceededSubscribers: []*pb.Subscriber{}, + FailedSubscribers: []*pb.Subscriber{}, + InProgressSubscribers: []*pb.Subscriber{}, + } + + //Get Reconcilers by ManifestsEndpoint + total_subscribers, err := s.dbClient.Query(ctx, db.CountByManifestsEndpoint, deploymentStateRequest.ManifestsEndpoint) + if err != nil { + return nil, err + } + + deployment_state.TotalSubscribers = total_subscribers.(int32) + + if deployment_state.TotalSubscribers > 0 { + //Get DeploymentStatuses by ManifestsEndpoint and GitopsCommitId + deployment_statuses, err := s.dbClient.Query(ctx, db.CountByStatuses, deploymentStateRequest.ManifestsEndpoint, deploymentStateRequest.CommitId) + if err != nil { + return nil, err + } + + status := deployment_statuses.(db.StatusStats) + deployment_state.TotalSucceededSubscribers = status.Success + deployment_state.TotalFailedSubscribers = status.Failed + deployment_state.TotalInProgressSubscribers = status.InProgress + + if deployment_state.TotalFailedSubscribers > 0 { + failed_deployments, err := s.dbClient.Query(ctx, db.GetByStatus, deploymentStateRequest.ManifestsEndpoint, deploymentStateRequest.CommitId, "failure") + if err != nil { + return nil, err + } + for _, deployment := range failed_deployments.([]map[string]string) { + subscriber := &pb.Subscriber{ + Name: deployment["name"], + StatusMessage: deployment["status_message"], + } + deployment_state.FailedSubscribers = append(deployment_state.FailedSubscribers, subscriber) + } + } + + } + + return deployment_state, nil + +} + func newStorageApiServer(dbClient db.DBClient) *storageApiServer { return &storageApiServer{dbClient: dbClient} } @@ -396,25 +455,65 @@ func readConfigValuesFromEnv() { } +func getDeploymentStateHandler(c *gin.Context) { + var req pb.DeploymentStateRequest + if err := c.ShouldBindJSON(&req); err != nil { + c.JSON(400, gin.H{"error": err.Error()}) + return + } + + resp, err := server.GetDeploymentState(c, &req) + if err != nil { + c.JSON(500, gin.H{"error": err.Error()}) + return + } + + c.JSON(200, resp) + +} + func main() { flag.Parse() readConfigValuesFromEnv() - lis, err := net.Listen("tcp", fmt.Sprintf(":%d", portInt)) - if err != nil { - log.Fatalf("failed to listen: %v", err) - } + // lis, err := net.Listen("tcp", fmt.Sprintf(":%d", portInt)) + // if err != nil { + // log.Fatalf("failed to listen: %v", err) + // } grpcServer := grpc.NewServer() grpc_health_v1.RegisterHealthServer(grpcServer, health.NewServer()) dbClient := db.NewPostgresClient(*postgresHost, postgresPortInt, *postgresUser, *postgresPassword, *postgresDbName, *postgresSslmode) - pb.RegisterStorageApiServer(grpcServer, newStorageApiServer(dbClient)) + server = newStorageApiServer(dbClient) + pb.RegisterStorageApiServer(grpcServer, server) + router := gin.Default() + + router.POST("/deployment_state", getDeploymentStateHandler) + //log starting the server log.Printf("Starting server on port %d", portInt) - err = grpcServer.Serve(lis) - if err != nil { + // err = grpcServer.Serve(lis) + // if err != nil { + // log.Fatalf("failed to serve: %v", err) + // } + + httpServer := &http.Server{ + Addr: fmt.Sprintf(":%d", portInt), + Handler: h2c.NewHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // Detect if it's a gRPC request or HTTP request + if r.ProtoMajor == 2 && r.Header.Get("content-type") == "application/grpc" { + grpcServer.ServeHTTP(w, r) + } else { + router.ServeHTTP(w, r) + } + }), &http2.Server{}), + } + + log.Println("Serving gRPC and HTTP on :50051") + + if err := httpServer.ListenAndServe(); err != nil { log.Fatalf("failed to serve: %v", err) } diff --git a/storage/go.mod b/storage/go.mod index 2452c02..d79b025 100644 --- a/storage/go.mod +++ b/storage/go.mod @@ -3,15 +3,38 @@ module github.com/microsoft/kalypso-observability-hub/storage go 1.19 require ( + github.com/gin-gonic/gin v1.10.0 github.com/lib/pq v1.10.9 + golang.org/x/net v0.25.0 google.golang.org/grpc v1.56.3 - google.golang.org/protobuf v1.33.0 + google.golang.org/protobuf v1.34.1 ) require ( + github.com/bytedance/sonic v1.11.6 // indirect + github.com/bytedance/sonic/loader v0.1.1 // indirect + github.com/cloudwego/base64x v0.1.4 // indirect + github.com/cloudwego/iasm v0.2.0 // indirect + github.com/gabriel-vasile/mimetype v1.4.3 // indirect + github.com/gin-contrib/sse v0.1.0 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.20.0 // indirect + github.com/goccy/go-json v0.10.2 // indirect github.com/golang/protobuf v1.5.3 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/cpuid/v2 v2.2.7 // indirect + github.com/leodido/go-urn v1.4.0 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/pelletier/go-toml/v2 v2.2.2 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/ugorji/go/codec v1.2.12 // indirect + golang.org/x/arch v0.8.0 // indirect + golang.org/x/crypto v0.23.0 // indirect + golang.org/x/sys v0.20.0 // indirect + golang.org/x/text v0.15.0 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/storage/go.sum b/storage/go.sum index de5a487..c5f044f 100644 --- a/storage/go.sum +++ b/storage/go.sum @@ -1,16 +1,85 @@ +github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0= +github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= +github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= +github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= +github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= +github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= +github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= +github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= +github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= +github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= +github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= +github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= +github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= +github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= +github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= +github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= +github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= +golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= +golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= @@ -18,5 +87,12 @@ google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg= +google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/storage/postgres/postgres_client.go b/storage/postgres/postgres_client.go index ebdbd2f..c0b115c 100644 --- a/storage/postgres/postgres_client.go +++ b/storage/postgres/postgres_client.go @@ -15,10 +15,13 @@ type Entity interface { getByNaturalKey(conn *sql.DB) (Entity, error) } +type QueryFunc func(conn *sql.DB, args ...interface{}) (interface{}, error) + type DBClient interface { Update(ctx context.Context, enity Entity) (Entity, error) Get(ctx context.Context, enity Entity) (Entity, error) GetByNaturalKey(ctx context.Context, enity Entity) (Entity, error) + Query(ctx context.Context, query QueryFunc, args ...interface{}) (interface{}, error) } type postgresClient struct { @@ -83,3 +86,17 @@ func (c *postgresClient) GetByNaturalKey(ctx context.Context, entity Entity) (En } return entity, nil } + +func (c *postgresClient) Query(ctx context.Context, query QueryFunc, args ...interface{}) (interface{}, error) { + conn, err := c.getConnection() + if err != nil { + return nil, err + } + defer conn.Close() + entities, err := query(conn, args...) + if err != nil { + log.Printf("fail to query entities: %v", err) + return nil, err + } + return entities, nil +} diff --git a/storage/postgres/reconciler.go b/storage/postgres/reconciler.go index 321e338..3e95f7e 100644 --- a/storage/postgres/reconciler.go +++ b/storage/postgres/reconciler.go @@ -1,6 +1,8 @@ package postgres -import "database/sql" +import ( + "database/sql" +) type Reconciler struct { Id int @@ -13,6 +15,12 @@ type Reconciler struct { ManifestsEndpoint string } +type StatusStats struct { + Success int32 + Failed int32 + InProgress int32 +} + // make sure that the Host implements the Entity interface var _ Entity = (*Reconciler)(nil) @@ -51,3 +59,71 @@ func (r *Reconciler) getByNaturalKey(conn *sql.DB) (Entity, error) { } return r, nil } + +var _ QueryFunc = CountByManifestsEndpoint + +func CountByManifestsEndpoint(conn *sql.DB, args ...interface{}) (interface{}, error) { + var count int32 + + manifest_endpoint := args[0].(string) + err := conn.QueryRow(`SELECT count(1) FROM reconciler WHERE manifests_endpoint like $1`, manifest_endpoint).Scan(&count) + if err != nil { + return nil, err + } + return count, nil +} + +var _ QueryFunc = CountByStatuses + +func CountByStatuses(conn *sql.DB, args ...interface{}) (interface{}, error) { + + status := StatusStats{} + + manifest_endpoint := args[0].(string) + gitops_commit_id := args[1].(string) + err := conn.QueryRow(`SELECT count(case when status='success' then 1 end) as success, + count(case when status='failure' then 1 end) as failed, + count(case when status='in_progress' then 1 end) as in_progress + FROM reconciler r, deployment d + WHERE r.id = d.reconciler_id and + r.manifests_endpoint like $1 and + d.gitops_commit_id = $2`, + manifest_endpoint, gitops_commit_id).Scan(&status.Success, &status.Failed, &status.InProgress) + if err != nil { + return nil, err + } + return status, nil +} + +var _ QueryFunc = GetByStatus + +func GetByStatus(conn *sql.DB, args ...interface{}) (interface{}, error) { + manifest_endpoint := args[0].(string) + gitops_commit_id := args[1].(string) + status := args[2].(string) + reconcilers := make([]map[string]string, 0) + + rows, err := conn.Query(`SELECT r.name, d.status_message + FROM reconciler r, deployment d + WHERE r.id = d.reconciler_id and + r.manifests_endpoint like $1 and + d.gitops_commit_id = $2 and + d.status = $3`, + manifest_endpoint, gitops_commit_id, status) + if err != nil { + return nil, err + } + defer rows.Close() + for rows.Next() { + var reconciler_name string + var reconciler_status_message string + + err := rows.Scan(&reconciler_name, &reconciler_status_message) + if err != nil { + return nil, err + } + reconcilers = append(reconcilers, map[string]string{"name": reconciler_name, "status_message": reconciler_status_message}) + } + return reconcilers, nil + +}