Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/cli/cmd/available_integration_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package cmd

import (
"fmt"
"strings"

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

t := newTableWriter()
t.AppendHeader(table.Row{"ID", "Version", "Description"})
t.AppendHeader(table.Row{"ID", "Version", "Material Requirement", "Description"})
for _, i := range items {
t.AppendRow(table.Row{i.ID, i.Version, i.Description})
t.AppendRow(table.Row{i.ID, i.Version, strings.Join(i.SubscribedInputs, ", "), i.Description})
t.AppendSeparator()
}

Expand Down
20 changes: 16 additions & 4 deletions app/cli/internal/action/available_integration_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ type AvailableIntegrationItem struct {
Description string `json:"description,omitempty"`
Registration *JSONSchema `json:"registration"`
Attachment *JSONSchema `json:"attachment"`
// Subscribed inputs (material types)
SubscribedInputs []string `json:"subscribedInputs"`
}

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

if in.GetFanout() == nil {
fmt.Printf("skipping integration %s, type not supported\n", in.GetId())
return nil, nil
}

foType := in.GetFanout()

i := &AvailableIntegrationItem{
ID: in.GetId(), Version: in.GetVersion(), Description: in.GetDescription(),
Registration: &JSONSchema{Raw: string(in.GetRegistrationSchema())},
Attachment: &JSONSchema{Raw: string(in.GetAttachmentSchema())},
Registration: &JSONSchema{Raw: string(foType.GetRegistrationSchema())},
Attachment: &JSONSchema{Raw: string(foType.GetAttachmentSchema())},
}

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

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

// Subscribed inputs
i.SubscribedInputs = append(i.SubscribedInputs, foType.GetSubscribedMaterials()...)

return i, nil
}

Expand Down
Loading