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
6 changes: 5 additions & 1 deletion app/cli/cmd/casbackend.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2023 The Chainloop Authors.
// Copyright 2024 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 Down Expand Up @@ -40,6 +40,9 @@ func newCASBackendAddCmd() *cobra.Command {

cmd.PersistentFlags().Bool("default", false, "set the backend as default in your organization")
cmd.PersistentFlags().String("description", "", "descriptive information for this registration")
cmd.PersistentFlags().String("name", "", "CAS backend name")
err := cmd.MarkPersistentFlagRequired("name")
cobra.CheckErr(err)

cmd.AddCommand(newCASBackendAddOCICmd(), newCASBackendAddAzureBlobStorageCmd(), newCASBackendAddAWSS3Cmd())
return cmd
Expand All @@ -53,6 +56,7 @@ func newCASBackendUpdateCmd() *cobra.Command {

cmd.PersistentFlags().Bool("default", false, "set the backend as default in your organization")
cmd.PersistentFlags().String("description", "", "descriptive information for this registration")
cmd.PersistentFlags().String("name", "", "CAS backend name")

cmd.AddCommand(newCASBackendUpdateOCICmd(), newCASBackendUpdateInlineCmd(), newCASBackendUpdateAzureBlobCmd(), newCASBackendUpdateAWSS3Cmd())
return cmd
Expand Down
6 changes: 5 additions & 1 deletion app/cli/cmd/casbackend_add_azureblob.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2023 The Chainloop Authors.
// Copyright 2024 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 Down Expand Up @@ -35,6 +35,9 @@ func newCASBackendAddAzureBlobStorageCmd() *cobra.Command {
isDefault, err := cmd.Flags().GetBool("default")
cobra.CheckErr(err)

name, err := cmd.Flags().GetString("name")
cobra.CheckErr(err)

description, err := cmd.Flags().GetString("description")
cobra.CheckErr(err)

Expand All @@ -48,6 +51,7 @@ func newCASBackendAddAzureBlobStorageCmd() *cobra.Command {
}

opts := &action.NewCASBackendAddOpts{
Name: name,
Location: fmt.Sprintf("%s/%s", storageAccountName, container),
Provider: azureblob.ProviderID,
Description: description,
Expand Down
6 changes: 5 additions & 1 deletion app/cli/cmd/casbackend_add_oci.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2023 The Chainloop Authors.
// Copyright 2024 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 Down Expand Up @@ -32,6 +32,9 @@ func newCASBackendAddOCICmd() *cobra.Command {
isDefault, err := cmd.Flags().GetBool("default")
cobra.CheckErr(err)

name, err := cmd.Flags().GetString("name")
cobra.CheckErr(err)

description, err := cmd.Flags().GetString("description")
cobra.CheckErr(err)

Expand All @@ -45,6 +48,7 @@ func newCASBackendAddOCICmd() *cobra.Command {
}

opts := &action.NewCASBackendAddOpts{
Name: name,
Location: repo, Description: description,
Provider: "OCI",
Credentials: map[string]any{
Expand Down
6 changes: 5 additions & 1 deletion app/cli/cmd/casbackend_add_s3.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2023 The Chainloop Authors.
// Copyright 2024 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 Down Expand Up @@ -31,6 +31,9 @@ func newCASBackendAddAWSS3Cmd() *cobra.Command {
isDefault, err := cmd.Flags().GetBool("default")
cobra.CheckErr(err)

name, err := cmd.Flags().GetString("name")
cobra.CheckErr(err)

description, err := cmd.Flags().GetString("description")
cobra.CheckErr(err)

Expand All @@ -44,6 +47,7 @@ func newCASBackendAddAWSS3Cmd() *cobra.Command {
}

opts := &action.NewCASBackendAddOpts{
Name: name,
Location: bucketName,
Provider: s3.ProviderID,
Description: description,
Expand Down
4 changes: 2 additions & 2 deletions app/cli/cmd/casbackend_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func casBackendListTableOutput(backends []*action.CASBackendItem) error {
}

t := newTableWriter()
header := table.Row{"ID", "Location", "Provider", "Description", "Limits", "Default"}
header := table.Row{"ID", "Name", "Location", "Provider", "Description", "Limits", "Default"}
if full {
header = append(header, "Validation Status", "Created At", "Validated At")
}
Expand All @@ -64,7 +64,7 @@ func casBackendListTableOutput(backends []*action.CASBackendItem) error {
limits = fmt.Sprintf("MaxSize: %s", bytefmt.ByteSize(uint64(b.Limits.MaxBytes)))
}

r := table.Row{b.ID, wrap.String(b.Location, 35), b.Provider, wrap.String(b.Description, 35), limits, b.Default}
r := table.Row{b.ID, b.Name, wrap.String(b.Location, 35), b.Provider, wrap.String(b.Description, 35), limits, b.Default}
if full {
r = append(r, b.ValidationStatus,
b.CreatedAt.Format(time.RFC822),
Expand Down
6 changes: 5 additions & 1 deletion app/cli/cmd/casbackend_update_azureblob.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2023 The Chainloop Authors.
// Copyright 2024 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 Down Expand Up @@ -35,6 +35,9 @@ func newCASBackendUpdateAzureBlobCmd() *cobra.Command {
description, err := cmd.Flags().GetString("description")
cobra.CheckErr(err)

name, err := cmd.Flags().GetString("name")
cobra.CheckErr(err)

// If we are overriding the default we ask for confirmation
if isDefault {
if confirmed, err := confirmDefaultCASBackendOverride(actionOpts, backendID); err != nil {
Expand All @@ -55,6 +58,7 @@ func newCASBackendUpdateAzureBlobCmd() *cobra.Command {

opts := &action.NewCASBackendUpdateOpts{
ID: backendID,
Name: name,
Description: description,
Credentials: map[string]any{
"tenantID": tenantID,
Expand Down
6 changes: 5 additions & 1 deletion app/cli/cmd/casbackend_update_inline.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2023 The Chainloop Authors.
// Copyright 2024 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 Down Expand Up @@ -33,6 +33,9 @@ func newCASBackendUpdateInlineCmd() *cobra.Command {
description, err := cmd.Flags().GetString("description")
cobra.CheckErr(err)

name, err := cmd.Flags().GetString("name")
cobra.CheckErr(err)

// If we are overriding the default we ask for confirmation
if isDefault {
if confirmed, err := confirmDefaultCASBackendOverride(actionOpts, backendID); err != nil {
Expand All @@ -52,6 +55,7 @@ func newCASBackendUpdateInlineCmd() *cobra.Command {
}

opts := &action.NewCASBackendUpdateOpts{
Name: name,
ID: backendID,
Description: description,
Default: isDefault,
Expand Down
6 changes: 5 additions & 1 deletion app/cli/cmd/casbackend_update_oci.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2023 The Chainloop Authors.
// Copyright 2024 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 Down Expand Up @@ -35,6 +35,9 @@ func newCASBackendUpdateOCICmd() *cobra.Command {
description, err := cmd.Flags().GetString("description")
cobra.CheckErr(err)

name, err := cmd.Flags().GetString("name")
cobra.CheckErr(err)

// If we are overriding the default we ask for confirmation
if isDefault {
if confirmed, err := confirmDefaultCASBackendOverride(actionOpts, backendID); err != nil {
Expand All @@ -55,6 +58,7 @@ func newCASBackendUpdateOCICmd() *cobra.Command {

opts := &action.NewCASBackendUpdateOpts{
ID: backendID,
Name: name,
Description: description,
Credentials: map[string]any{
"username": username,
Expand Down
6 changes: 5 additions & 1 deletion app/cli/cmd/casbackend_update_s3.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2023 The Chainloop Authors.
// Copyright 2024 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 Down Expand Up @@ -35,6 +35,9 @@ func newCASBackendUpdateAWSS3Cmd() *cobra.Command {
description, err := cmd.Flags().GetString("description")
cobra.CheckErr(err)

name, err := cmd.Flags().GetString("name")
cobra.CheckErr(err)

// If we are overriding the default we ask for confirmation
if isDefault {
if confirmed, err := confirmDefaultCASBackendOverride(actionOpts, backendID); err != nil {
Expand All @@ -55,6 +58,7 @@ func newCASBackendUpdateAWSS3Cmd() *cobra.Command {

opts := &action.NewCASBackendUpdateOpts{
ID: backendID,
Name: name,
Description: description,
Credentials: map[string]any{
"accessKeyID": accessKeyID,
Expand Down
2 changes: 2 additions & 0 deletions app/cli/internal/action/casbackend_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type CASBackendAdd struct {
}

type NewCASBackendAddOpts struct {
Name string
Location string
Provider string
Description string
Expand All @@ -48,6 +49,7 @@ func (action *CASBackendAdd) Run(opts *NewCASBackendAddOpts) (*CASBackendItem, e

client := pb.NewCASBackendServiceClient(action.cfg.CPConnection)
resp, err := client.Create(context.Background(), &pb.CASBackendServiceCreateRequest{
Name: opts.Name,
Location: opts.Location,
Provider: opts.Provider,
Description: opts.Description,
Expand Down
2 changes: 2 additions & 0 deletions app/cli/internal/action/casbackend_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type CASBackendList struct {

type CASBackendItem struct {
ID string `json:"id"`
Name string `json:"name"`
Location string `json:"location"`
Description string `json:"description"`
Provider string `json:"provider"`
Expand Down Expand Up @@ -78,6 +79,7 @@ func pbCASBackendItemToAction(in *pb.CASBackendItem) *CASBackendItem {

b := &CASBackendItem{
ID: in.Id,
Name: in.Name,
Location: in.Location,
Description: in.Description,
Provider: in.Provider,
Expand Down
2 changes: 2 additions & 0 deletions app/cli/internal/action/casbackend_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type CASBackendUpdate struct {

type NewCASBackendUpdateOpts struct {
ID string
Name string
Description string
Default bool
Credentials map[string]any
Expand All @@ -52,6 +53,7 @@ func (action *CASBackendUpdate) Run(opts *NewCASBackendUpdateOpts) (*CASBackendI
client := pb.NewCASBackendServiceClient(action.cfg.CPConnection)
resp, err := client.Update(context.Background(), &pb.CASBackendServiceUpdateRequest{
Id: opts.ID,
Name: opts.Name,
Description: opts.Description,
Default: opts.Default,
Credentials: credentials,
Expand Down
Loading