Skip to content

Commit

Permalink
Updated list service (#254)
Browse files Browse the repository at this point in the history
* Updated list service
  • Loading branch information
dhavalmehta07 authored Sep 20, 2024
1 parent 5f2e7bf commit 92c677e
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 254 deletions.
16 changes: 6 additions & 10 deletions cmd/list/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ var serviceCmd = &cobra.Command{
},
}

var serviceName, version, team, label string
var serviceName, version, tags string

func init() {
serviceCmd.Flags().StringVar(&serviceName, "name", "", "name of the service")
serviceCmd.Flags().StringVar(&version, "version", "", "version of services to be listed")
serviceCmd.Flags().StringVar(&team, "team", "", "name of team")
serviceCmd.Flags().StringVar(&label, "label", "", "name of label")
serviceCmd.Flags().StringVar(&tags, "tags", "", "comma separated tags eg. key1=value1,key2=value2")
listCmd.AddCommand(serviceCmd)
}

Expand All @@ -40,8 +39,7 @@ func listService(cmd *cobra.Command) {
response, err := serviceClient.ListService(&ctx, &serviceProto.ListServiceRequest{
Name: serviceName,
Version: version,
Team: team,
Label: label,
Tags: tags,
})

if err != nil {
Expand All @@ -67,14 +65,13 @@ func writeListService(response *serviceProto.ListServiceResponse, format string)
}

func writeListServiceAsText(response *serviceProto.ListServiceResponse) {
var tableHeaders = []string{"Name", "Version", "Label", "Description"}
var tableHeaders = []string{"Name", "Version", "Tags"}
var tableData [][]interface{}
for _, serviceEntity := range response.Services {
tableData = append(tableData, []interface{}{
serviceEntity.Name,
serviceEntity.Version,
serviceEntity.Labels,
serviceEntity.Description,
serviceEntity.Tags,
})
}
table.Write(tableHeaders, tableData)
Expand All @@ -86,8 +83,7 @@ func writeListServiceAsJSON(response *serviceProto.ListServiceResponse) {
services = append(services, map[string]interface{}{
"name": serviceEntity.Name,
"version": serviceEntity.Version,
"labels": serviceEntity.Labels,
"description": serviceEntity.Description,
"Tags": serviceEntity.Tags,
})
}
output, _ := json.MarshalIndent(services, "", " ")
Expand Down
13 changes: 3 additions & 10 deletions proto/dream11/od/dto/v1/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,9 @@ message ProvisioningConfig {
}

message ServiceMetadata {
int32 id = 1;
string name = 2;
string version = 3;
string description = 4;
string created_by = 5;
string updated_by = 6;
string created_at = 7;
string updated_at = 8;
string tags = 9; // JSON encoded string
string labels = 10; // comma seperated string
string name = 1;
string version = 2;
string tags = 3;
}

message AddComponentRequestOptions {
Expand Down
3 changes: 1 addition & 2 deletions proto/dream11/od/service/v1/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ message ListServiceResponse {
message ListServiceRequest {
string name = 1;
string version = 2;
string team = 3;
string label = 4;
string tags = 3;
}

message DescribeServiceRequest {
Expand Down
202 changes: 67 additions & 135 deletions proto/gen/go/dream11/od/dto/v1/service.pb.go

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

Loading

0 comments on commit 92c677e

Please sign in to comment.