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
3 changes: 2 additions & 1 deletion app/cli/cmd/attached_integration_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package cmd

import (
"github.com/chainloop-dev/chainloop/app/cli/cmd/output"
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -61,7 +62,7 @@ func newAttachedIntegrationAttachCmd() *cobra.Command {
return err
}

return encodeOutput([]*action.AttachedIntegrationItem{res}, attachedIntegrationListTableOutput)
return output.EncodeOutput(flagOutputFormat, []*action.AttachedIntegrationItem{res}, attachedIntegrationListTableOutput)
},
}

Expand Down
5 changes: 3 additions & 2 deletions app/cli/cmd/attached_integration_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"strings"
"time"

"github.com/chainloop-dev/chainloop/app/cli/cmd/output"
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/spf13/cobra"
Expand All @@ -38,7 +39,7 @@ func newAttachedIntegrationListCmd() *cobra.Command {
return err
}

return encodeOutput(res, attachedIntegrationListTableOutput)
return output.EncodeOutput(flagOutputFormat, res, attachedIntegrationListTableOutput)
},
}

Expand All @@ -58,7 +59,7 @@ func attachedIntegrationListTableOutput(attachments []*action.AttachedIntegratio
fmt.Println("Integrations attached to workflows")
}

t := newTableWriter()
t := output.NewTableWriter()
t.AppendHeader(table.Row{"ID", "Kind", "Config", "Workflow", "Attached At"})
for _, attachment := range attachments {
wf := attachment.Workflow
Expand Down
5 changes: 3 additions & 2 deletions app/cli/cmd/attestation_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/spf13/viper"
"google.golang.org/grpc"

"github.com/chainloop-dev/chainloop/app/cli/cmd/output"
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
schemaapi "github.com/chainloop-dev/chainloop/app/controlplane/api/workflowcontract/v1"
"github.com/chainloop-dev/chainloop/pkg/resourceloader"
Expand Down Expand Up @@ -118,7 +119,7 @@ func newAttestationAddCmd() *cobra.Command {
return err
}

return encodeOutput(resp, func(s *action.AttestationStatusMaterial) error {
return output.EncodeOutput(flagOutputFormat, resp, func(s *action.AttestationStatusMaterial) error {
return displayMaterialInfo(s, policies[resp.Name])
})
},
Expand Down Expand Up @@ -168,7 +169,7 @@ func displayMaterialInfo(status *action.AttestationStatusMaterial, policyEvaluat
return nil
}

mt := newTableWriter()
mt := output.NewTableWriter()

mt.AppendRow(table.Row{"Name", status.Material.Name})
mt.AppendRow(table.Row{"Type", status.Material.Type})
Expand Down
3 changes: 2 additions & 1 deletion app/cli/cmd/attestation_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"errors"
"fmt"

"github.com/chainloop-dev/chainloop/app/cli/cmd/output"
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -129,7 +130,7 @@ func newAttestationInitCmd() *cobra.Command {
logger.Warn().Msg("DEPRECATION WARNING: --project not set, this will be required in the near future")
}

return encodeOutput(res, fullStatusTable)
return output.EncodeOutput(flagOutputFormat, res, fullStatusTable)
}}

// This option is only useful for local-based attestation states
Expand Down
5 changes: 3 additions & 2 deletions app/cli/cmd/attestation_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"

"github.com/chainloop-dev/chainloop/app/cli/cmd/output"
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
)

Expand Down Expand Up @@ -106,7 +107,7 @@ func newAttestationPushCmd() *cobra.Command {
res.Status.Digest = res.Digest

// If we are returning the json format, we also want to render the attestation table as one property so it can also be consumed
if flagOutputFormat == formatJSON {
if flagOutputFormat == output.FormatJSON {
// Render the attestation status to a string
buf := &bytes.Buffer{}
if err := fullStatusTableWithWriter(res.Status, buf); err != nil {
Expand All @@ -117,7 +118,7 @@ func newAttestationPushCmd() *cobra.Command {
}

// In TABLE format, we render the attestation status
if err := encodeOutput(res.Status, fullStatusTable); err != nil {
if err := output.EncodeOutput(flagOutputFormat, res.Status, fullStatusTable); err != nil {
return fmt.Errorf("failed to render output: %w", err)
}

Expand Down
15 changes: 8 additions & 7 deletions app/cli/cmd/attestation_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/muesli/reflow/wrap"
"github.com/spf13/cobra"

"github.com/chainloop-dev/chainloop/app/cli/cmd/output"
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
"github.com/chainloop-dev/chainloop/pkg/attestation/renderer/chainloop"
)
Expand Down Expand Up @@ -58,12 +59,12 @@ func newAttestationStatusCmd() *cobra.Command {
return err
}

output := simpleStatusTable
outputF := simpleStatusTable
if full {
output = fullStatusTable
outputF = fullStatusTable
}

return encodeOutput(res, output)
return output.EncodeOutput(flagOutputFormat, res, outputF)
},
}

Expand All @@ -87,7 +88,7 @@ func fullStatusTableWithWriter(status *action.AttestationStatusResult, w io.Writ

func attestationStatusTableOutput(status *action.AttestationStatusResult, w io.Writer, full bool) error {
// General info table
gt := newTableWriterWithWriter(w)
gt := output.NewTableWriterWithWriter(w)
gt.AppendRow(table.Row{"Initialized At", status.InitializedAt.Format(time.RFC822)})
gt.AppendSeparator()
meta := status.WorkflowMeta
Expand Down Expand Up @@ -154,7 +155,7 @@ func envVarsTable(status *action.AttestationStatusResult, w io.Writer, full bool

if len(status.EnvVars) > 0 {
// Env Variables table
evt := newTableWriterWithWriter(w)
evt := output.NewTableWriterWithWriter(w)
evt.SetTitle("Env Variables")
for k, v := range status.EnvVars {
if v == "" {
Expand All @@ -167,7 +168,7 @@ func envVarsTable(status *action.AttestationStatusResult, w io.Writer, full bool

runnerVars := status.RunnerContext.EnvVars
if len(runnerVars) > 0 && full {
evt := newTableWriterWithWriter(w)
evt := output.NewTableWriterWithWriter(w)
evt.SetTitle("Runner context")
for k, v := range runnerVars {
if v == "" {
Expand All @@ -190,7 +191,7 @@ func materialsTable(status *action.AttestationStatusResult, w io.Writer, full bo
return strings.Compare(a.Name, b.Name)
})

mt := newTableWriterWithWriter(w)
mt := output.NewTableWriterWithWriter(w)
mt.SetTitle("Materials")

for _, m := range status.Materials {
Expand Down
7 changes: 4 additions & 3 deletions app/cli/cmd/available_integration_describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"sort"

"github.com/chainloop-dev/chainloop/app/cli/cmd/output"
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
"github.com/chainloop-dev/chainloop/app/controlplane/plugins/sdk/v1"
"github.com/jedib0t/go-pretty/v6/table"
Expand All @@ -44,7 +45,7 @@ func newAvailableIntegrationDescribeCmd() *cobra.Command {
return fmt.Errorf("integration %q not found", integrationName)
}

return encodeOutput([]*action.AvailableIntegrationItem{item}, availableIntegrationDescribeTableOutput)
return output.EncodeOutput(flagOutputFormat, []*action.AvailableIntegrationItem{item}, availableIntegrationDescribeTableOutput)
},
}

Expand Down Expand Up @@ -97,7 +98,7 @@ func renderSchemaTable(tableTitle string, properties sdk.SchemaPropertiesMap) er
return nil
}

t := newTableWriter()
t := output.NewTableWriter()
t.SetTitle(tableTitle)
t.AppendHeader(table.Row{"Field", "Type", "Required", "Description"})

Expand Down Expand Up @@ -143,7 +144,7 @@ func renderSchemaRaw(tableTitle string, s string) error {
return err
}

rt := newTableWriter()
rt := output.NewTableWriter()
rt.SetTitle(tableTitle)
rt.AppendRow(table.Row{prettyAttachmentJSON.String()})
rt.Render()
Expand Down
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 @@ -19,6 +19,7 @@ import (
"fmt"
"strings"

"github.com/chainloop-dev/chainloop/app/cli/cmd/output"
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/spf13/cobra"
Expand All @@ -35,7 +36,7 @@ func newAvailableIntegrationListCmd() *cobra.Command {
return err
}

return encodeOutput(res, availableIntegrationListTableOutput)
return output.EncodeOutput(flagOutputFormat, res, availableIntegrationListTableOutput)
},
}

Expand All @@ -48,7 +49,7 @@ func availableIntegrationListTableOutput(items []*action.AvailableIntegrationIte
return nil
}

t := newTableWriter()
t := output.NewTableWriter()
t.AppendHeader(table.Row{"Name", "Version", "Material Requirement", "Description"})
for _, i := range items {
t.AppendRow(table.Row{i.Name, i.Version, strings.Join(i.SubscribedInputs, ", "), i.Description})
Expand Down
3 changes: 2 additions & 1 deletion app/cli/cmd/casbackend_add_azureblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package cmd
import (
"fmt"

"github.com/chainloop-dev/chainloop/app/cli/cmd/output"
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
"github.com/chainloop-dev/chainloop/pkg/blobmanager/azureblob"
"github.com/go-kratos/kratos/v2/log"
Expand Down Expand Up @@ -70,7 +71,7 @@ func newCASBackendAddAzureBlobStorageCmd() *cobra.Command {
return nil
}

return encodeOutput(res, casBackendItemTableOutput)
return output.EncodeOutput(flagOutputFormat, res, casBackendItemTableOutput)
},
}

Expand Down
3 changes: 2 additions & 1 deletion app/cli/cmd/casbackend_add_oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package cmd

import (
"github.com/chainloop-dev/chainloop/app/cli/cmd/output"
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
"github.com/go-kratos/kratos/v2/log"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -65,7 +66,7 @@ func newCASBackendAddOCICmd() *cobra.Command {
return nil
}

return encodeOutput(res, casBackendItemTableOutput)
return output.EncodeOutput(flagOutputFormat, res, casBackendItemTableOutput)
},
}

Expand Down
3 changes: 2 additions & 1 deletion app/cli/cmd/casbackend_add_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package cmd
import (
"fmt"

"github.com/chainloop-dev/chainloop/app/cli/cmd/output"
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
"github.com/chainloop-dev/chainloop/pkg/blobmanager/s3"
"github.com/go-kratos/kratos/v2/log"
Expand Down Expand Up @@ -74,7 +75,7 @@ func newCASBackendAddAWSS3Cmd() *cobra.Command {
return nil
}

return encodeOutput(res, casBackendItemTableOutput)
return output.EncodeOutput(flagOutputFormat, res, casBackendItemTableOutput)
},
}

Expand Down
5 changes: 3 additions & 2 deletions app/cli/cmd/casbackend_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"time"

"code.cloudfoundry.org/bytefmt"
"github.com/chainloop-dev/chainloop/app/cli/cmd/output"
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
"github.com/jedib0t/go-pretty/v6/table"
"github.com/muesli/reflow/wrap"
Expand All @@ -38,7 +39,7 @@ func newCASBackendListCmd() *cobra.Command {
return err
}

return encodeOutput(res, casBackendListTableOutput)
return output.EncodeOutput(flagOutputFormat, res, casBackendListTableOutput)
},
}

Expand All @@ -56,7 +57,7 @@ func casBackendListTableOutput(backends []*action.CASBackendItem) error {
return nil
}

t := newTableWriter()
t := output.NewTableWriter()
header := table.Row{"Name", "Location", "Provider", "Description", "Limits", "Default", "Status"}
if full {
header = append(header, "Created At", "Validated At")
Expand Down
3 changes: 2 additions & 1 deletion app/cli/cmd/casbackend_update_azureblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package cmd

import (
"github.com/chainloop-dev/chainloop/app/cli/cmd/output"
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
"github.com/go-kratos/kratos/v2/log"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -63,7 +64,7 @@ func newCASBackendUpdateAzureBlobCmd() *cobra.Command {
return nil
}

return encodeOutput(res, casBackendItemTableOutput)
return output.EncodeOutput(flagOutputFormat, res, casBackendItemTableOutput)
},
}

Expand Down
3 changes: 2 additions & 1 deletion app/cli/cmd/casbackend_update_inline.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package cmd

import (
"github.com/chainloop-dev/chainloop/app/cli/cmd/output"
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
"github.com/go-kratos/kratos/v2/log"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -53,7 +54,7 @@ func newCASBackendUpdateInlineCmd() *cobra.Command {
return nil
}

return encodeOutput(res, casBackendItemTableOutput)
return output.EncodeOutput(flagOutputFormat, res, casBackendItemTableOutput)
},
}

Expand Down
3 changes: 2 additions & 1 deletion app/cli/cmd/casbackend_update_oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package cmd

import (
"github.com/chainloop-dev/chainloop/app/cli/cmd/output"
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
"github.com/go-kratos/kratos/v2/log"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -61,7 +62,7 @@ func newCASBackendUpdateOCICmd() *cobra.Command {
return nil
}

return encodeOutput(res, casBackendItemTableOutput)
return output.EncodeOutput(flagOutputFormat, res, casBackendItemTableOutput)
},
}

Expand Down
3 changes: 2 additions & 1 deletion app/cli/cmd/casbackend_update_s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package cmd

import (
"github.com/chainloop-dev/chainloop/app/cli/cmd/output"
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
"github.com/go-kratos/kratos/v2/log"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -63,7 +64,7 @@ func newCASBackendUpdateAWSS3Cmd() *cobra.Command {
return nil
}

return encodeOutput(res, casBackendItemTableOutput)
return output.EncodeOutput(flagOutputFormat, res, casBackendItemTableOutput)
},
}

Expand Down
6 changes: 4 additions & 2 deletions app/cli/cmd/options/options.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2023 The Chainloop Authors.
// Copyright 2023-2025 The Chainloop Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,7 +15,9 @@

package options

import "github.com/spf13/cobra"
import (
"github.com/spf13/cobra"
)

type Interface interface {
// AddFlags adds this options' flags to the cobra command.
Expand Down
Loading
Loading