Skip to content

Commit b2309f2

Browse files
authored
feat(extensions): show required materials (#173)
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
1 parent 15d7af7 commit b2309f2

7 files changed

Lines changed: 671 additions & 342 deletions

File tree

app/cli/cmd/available_integration_list.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package cmd
1717

1818
import (
1919
"fmt"
20+
"strings"
2021

2122
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
2223
"github.com/jedib0t/go-pretty/v6/table"
@@ -50,9 +51,9 @@ func availableIntegrationListTableOutput(items []*action.AvailableIntegrationIte
5051
fmt.Println("Available integrations ready to be used during registration")
5152

5253
t := newTableWriter()
53-
t.AppendHeader(table.Row{"ID", "Version", "Description"})
54+
t.AppendHeader(table.Row{"ID", "Version", "Material Requirement", "Description"})
5455
for _, i := range items {
55-
t.AppendRow(table.Row{i.ID, i.Version, i.Description})
56+
t.AppendRow(table.Row{i.ID, i.Version, strings.Join(i.SubscribedInputs, ", "), i.Description})
5657
t.AppendSeparator()
5758
}
5859

app/cli/internal/action/available_integration_list.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ type AvailableIntegrationItem struct {
3636
Description string `json:"description,omitempty"`
3737
Registration *JSONSchema `json:"registration"`
3838
Attachment *JSONSchema `json:"attachment"`
39+
// Subscribed inputs (material types)
40+
SubscribedInputs []string `json:"subscribedInputs"`
3941
}
4042

4143
type JSONSchema struct {
@@ -90,20 +92,27 @@ func pbAvailableIntegrationItemToAction(in *pb.IntegrationAvailableItem) (*Avail
9092
return nil, errors.New("nil input")
9193
}
9294

95+
if in.GetFanout() == nil {
96+
fmt.Printf("skipping integration %s, type not supported\n", in.GetId())
97+
return nil, nil
98+
}
99+
100+
foType := in.GetFanout()
101+
93102
i := &AvailableIntegrationItem{
94103
ID: in.GetId(), Version: in.GetVersion(), Description: in.GetDescription(),
95-
Registration: &JSONSchema{Raw: string(in.GetRegistrationSchema())},
96-
Attachment: &JSONSchema{Raw: string(in.GetAttachmentSchema())},
104+
Registration: &JSONSchema{Raw: string(foType.GetRegistrationSchema())},
105+
Attachment: &JSONSchema{Raw: string(foType.GetAttachmentSchema())},
97106
}
98107

99108
// Parse the schemas so they can be used for validation or other purposes
100109
var err error
101-
i.Registration.Parsed, err = compileJSONSchema(in.GetRegistrationSchema())
110+
i.Registration.Parsed, err = compileJSONSchema(foType.GetRegistrationSchema())
102111
if err != nil {
103112
return nil, fmt.Errorf("failed to compile registration schema: %w", err)
104113
}
105114

106-
i.Attachment.Parsed, err = compileJSONSchema(in.GetAttachmentSchema())
115+
i.Attachment.Parsed, err = compileJSONSchema(foType.GetAttachmentSchema())
107116
if err != nil {
108117
return nil, fmt.Errorf("failed to compile registration schema: %w", err)
109118
}
@@ -119,6 +128,9 @@ func pbAvailableIntegrationItemToAction(in *pb.IntegrationAvailableItem) (*Avail
119128
return nil, fmt.Errorf("failed to calculate attachment properties: %w", err)
120129
}
121130

131+
// Subscribed inputs
132+
i.SubscribedInputs = append(i.SubscribedInputs, foType.GetSubscribedMaterials()...)
133+
122134
return i, nil
123135
}
124136

0 commit comments

Comments
 (0)