Skip to content

Commit eeddc26

Browse files
authored
chore(integrations); move from id to name (#1051)
Signed-off-by: Miguel Martinez Trivino <[email protected]>
1 parent 3f5df7a commit eeddc26

File tree

12 files changed

+347
-266
lines changed

12 files changed

+347
-266
lines changed

app/cli/cmd/attached_integration_add.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2023 The Chainloop Authors.
2+
// Copyright 2024 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ import (
2222

2323
func newAttachedIntegrationAttachCmd() *cobra.Command {
2424
var options []string
25-
var integrationID, workflowID string
25+
var integrationName, workflowName string
2626

2727
cmd := &cobra.Command{
2828
Use: "add",
@@ -31,7 +31,7 @@ func newAttachedIntegrationAttachCmd() *cobra.Command {
3131
Example: ` chainloop integration attached add --workflow deadbeef --integration beefdoingwell --opt projectName=MyProject --opt projectVersion=1.0.0`,
3232
RunE: func(cmd *cobra.Command, args []string) error {
3333
// Find the integration to extract the kind of integration we care about
34-
integration, err := action.NewRegisteredIntegrationDescribe(actionOpts).Run(integrationID)
34+
integration, err := action.NewRegisteredIntegrationDescribe(actionOpts).Run(integrationName)
3535
if err != nil {
3636
return err
3737
}
@@ -52,7 +52,7 @@ func newAttachedIntegrationAttachCmd() *cobra.Command {
5252
return err
5353
}
5454

55-
res, err := action.NewAttachedIntegrationAdd(actionOpts).Run(integrationID, workflowID, opts)
55+
res, err := action.NewAttachedIntegrationAdd(actionOpts).Run(integrationName, workflowName, opts)
5656
if err != nil {
5757
return err
5858
}
@@ -61,10 +61,10 @@ func newAttachedIntegrationAttachCmd() *cobra.Command {
6161
},
6262
}
6363

64-
cmd.Flags().StringVar(&integrationID, "integration", "", "ID of the integration already registered in this organization")
64+
cmd.Flags().StringVar(&integrationName, "integration", "", "Name of the integration already registered in this organization")
6565
cobra.CheckErr(cmd.MarkFlagRequired("integration"))
6666

67-
cmd.Flags().StringVar(&workflowID, "workflow", "", "ID of the workflow to attach this integration")
67+
cmd.Flags().StringVar(&workflowName, "workflow", "", "name of the workflow to attach this integration")
6868
cobra.CheckErr(cmd.MarkFlagRequired("workflow"))
6969

7070
// StringSlice seems to struggle with comma-separated values such as p12 jsonKeys provided as passwords

app/cli/cmd/attached_integration_list.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2023 The Chainloop Authors.
2+
// Copyright 2024 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -27,12 +27,13 @@ import (
2727
)
2828

2929
func newAttachedIntegrationListCmd() *cobra.Command {
30+
var workflowName string
3031
cmd := &cobra.Command{
3132
Use: "list",
3233
Aliases: []string{"ls"},
3334
Short: "List integrations attached to workflows",
3435
RunE: func(cmd *cobra.Command, args []string) error {
35-
res, err := action.NewAttachedIntegrationList(actionOpts).Run()
36+
res, err := action.NewAttachedIntegrationList(actionOpts).Run(workflowName)
3637
if err != nil {
3738
return err
3839
}
@@ -41,6 +42,7 @@ func newAttachedIntegrationListCmd() *cobra.Command {
4142
},
4243
}
4344

45+
cmd.Flags().StringVar(&workflowName, "workflow", "", "workflow name")
4446
return cmd
4547
}
4648

@@ -54,7 +56,7 @@ func attachedIntegrationListTableOutput(attachments []*action.AttachedIntegratio
5456
}
5557

5658
t := newTableWriter()
57-
t.AppendHeader(table.Row{"ID", "Kind", "Config", "Attached At", "Workflow"})
59+
t.AppendHeader(table.Row{"ID", "Kind", "Config", "Workflow", "Attached At"})
5860
for _, attachment := range attachments {
5961
wf := attachment.Workflow
6062
integration := attachment.Integration
@@ -80,7 +82,7 @@ func attachedIntegrationListTableOutput(attachments []*action.AttachedIntegratio
8082
options = append(options, fmt.Sprintf("%s: %v", k, v))
8183
}
8284

83-
t.AppendRow(table.Row{attachment.ID, integration.Kind, strings.Join(options, "\n"), attachment.CreatedAt.Format(time.RFC822), wf.NamespacedName()})
85+
t.AppendRow(table.Row{attachment.ID, integration.Kind, strings.Join(options, "\n"), wf.Name, attachment.CreatedAt.Format(time.RFC822)})
8486
t.AppendSeparator()
8587
}
8688

app/cli/cmd/available_integration_list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func availableIntegrationListTableOutput(items []*action.AvailableIntegrationIte
5151
t := newTableWriter()
5252
t.AppendHeader(table.Row{"Name", "Version", "Material Requirement", "Description"})
5353
for _, i := range items {
54-
t.AppendRow(table.Row{i.ID, i.Version, strings.Join(i.SubscribedInputs, ", "), i.Description})
54+
t.AppendRow(table.Row{i.Name, i.Version, strings.Join(i.SubscribedInputs, ", "), i.Description})
5555
t.AppendSeparator()
5656
}
5757

app/cli/internal/action/attached_integration_add.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2023 The Chainloop Authors.
2+
// Copyright 2024 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ func NewAttachedIntegrationAdd(cfg *ActionsOpts) *AttachedIntegrationAdd {
3030
return &AttachedIntegrationAdd{cfg}
3131
}
3232

33-
func (action *AttachedIntegrationAdd) Run(integrationID, workflowID string, options map[string]any) (*AttachedIntegrationItem, error) {
33+
func (action *AttachedIntegrationAdd) Run(integrationName, workflowName string, options map[string]any) (*AttachedIntegrationItem, error) {
3434
client := pb.NewIntegrationsServiceClient(action.cfg.CPConnection)
3535

3636
requestConfig, err := structpb.NewStruct(options)
@@ -39,9 +39,8 @@ func (action *AttachedIntegrationAdd) Run(integrationID, workflowID string, opti
3939
}
4040

4141
resp, err := client.Attach(context.Background(), &pb.IntegrationsServiceAttachRequest{
42-
WorkflowId: workflowID, IntegrationId: integrationID, Config: requestConfig,
42+
WorkflowName: workflowName, IntegrationName: integrationName, Config: requestConfig,
4343
})
44-
4544
if err != nil {
4645
return nil, err
4746
}

app/cli/internal/action/attached_integration_list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2023 The Chainloop Authors.
2+
// Copyright 2024 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -29,10 +29,10 @@ func NewAttachedIntegrationList(cfg *ActionsOpts) *AttachedIntegrationList {
2929
return &AttachedIntegrationList{cfg}
3030
}
3131

32-
func (action *AttachedIntegrationList) Run() ([]*AttachedIntegrationItem, error) {
32+
func (action *AttachedIntegrationList) Run(workflowName string) ([]*AttachedIntegrationItem, error) {
3333
client := pb.NewIntegrationsServiceClient(action.cfg.CPConnection)
3434

35-
resp, err := client.ListAttachments(context.Background(), &pb.ListAttachmentsRequest{})
35+
resp, err := client.ListAttachments(context.Background(), &pb.ListAttachmentsRequest{WorkflowName: workflowName})
3636
if err != nil {
3737
return nil, err
3838
}

app/cli/internal/action/available_integration_describe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (action *AvailableIntegrationDescribe) Run(name string) (*AvailableIntegrat
3737
}
3838

3939
for _, i := range resp.Result {
40-
if i.Id == name {
40+
if i.Name == name {
4141
return pbAvailableIntegrationItemToAction(i)
4242
}
4343
}

app/cli/internal/action/available_integration_list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type AvailableIntegrationList struct {
3030
}
3131

3232
type AvailableIntegrationItem struct {
33-
ID string `json:"id"`
33+
Name string `json:"name"`
3434
Version string `json:"version"`
3535
Description string `json:"description,omitempty"`
3636
Registration *JSONSchema `json:"registration"`
@@ -78,14 +78,14 @@ func pbAvailableIntegrationItemToAction(in *pb.IntegrationAvailableItem) (*Avail
7878
}
7979

8080
if in.GetFanout() == nil {
81-
fmt.Printf("skipping integration %s, type not supported\n", in.GetId())
81+
fmt.Printf("skipping integration %s, type not supported\n", in.GetName())
8282
return nil, nil
8383
}
8484

8585
foType := in.GetFanout()
8686

8787
i := &AvailableIntegrationItem{
88-
ID: in.GetId(), Version: in.GetVersion(), Description: in.GetDescription(),
88+
Name: in.GetName(), Version: in.GetVersion(), Description: in.GetDescription(),
8989
Registration: &JSONSchema{Raw: string(foType.GetRegistrationSchema())},
9090
Attachment: &JSONSchema{Raw: string(foType.GetAttachmentSchema())},
9191
}

app/cli/internal/action/registered_integration_describe.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ func NewRegisteredIntegrationDescribe(cfg *ActionsOpts) *RegisteredIntegrationDe
2929
return &RegisteredIntegrationDescribe{cfg}
3030
}
3131

32-
func (action *RegisteredIntegrationDescribe) Run(id string) (*RegisteredIntegrationItem, error) {
32+
func (action *RegisteredIntegrationDescribe) Run(name string) (*RegisteredIntegrationItem, error) {
3333
client := pb.NewIntegrationsServiceClient(action.cfg.CPConnection)
3434
resp, err := client.DescribeRegistration(context.Background(), &pb.IntegrationsServiceDescribeRegistrationRequest{
35-
Id: id,
35+
Name: name,
3636
})
3737
if err != nil {
3838
return nil, err

0 commit comments

Comments
 (0)