Skip to content

Commit 7285e32

Browse files
committed
revert
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
1 parent efd5443 commit 7285e32

58 files changed

Lines changed: 132 additions & 189 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/cli/cmd/casbackend.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package cmd
1818
import (
1919
"fmt"
2020

21-
"github.com/chainloop-dev/chainloop/app/cli/cmd/options"
2221
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
2322
"github.com/spf13/cobra"
2423
)
@@ -70,7 +69,7 @@ func newCASBackendUpdateCmd() *cobra.Command {
7069

7170
// confirmDefaultCASBackendOverride asks the user to confirm the override of the default CAS backend
7271
// in the event that there is one already set and its not the same as the one we are setting
73-
func confirmDefaultCASBackendOverride(actionOpts *options.ActionsOpts, id string) (bool, error) {
72+
func confirmDefaultCASBackendOverride(actionOpts *action.ActionsOpts, id string) (bool, error) {
7473
// get existing backends
7574
backends, err := action.NewCASBackendList(actionOpts).Run()
7675
if err != nil {
@@ -96,11 +95,11 @@ func confirmDefaultCASBackendOverride(actionOpts *options.ActionsOpts, id string
9695
}
9796

9897
// If we are removing the default we confirm too
99-
func confirmDefaultCASBackendRemoval(actionOpts *options.ActionsOpts, name string) (bool, error) {
98+
func confirmDefaultCASBackendRemoval(actionOpts *action.ActionsOpts, name string) (bool, error) {
10099
return confirmDefaultCASBackendUnset(name, "You are deleting the default CAS backend.", actionOpts)
101100
}
102101

103-
func confirmDefaultCASBackendUnset(name, msg string, actionOpts *options.ActionsOpts) (bool, error) {
102+
func confirmDefaultCASBackendUnset(name, msg string, actionOpts *action.ActionsOpts) (bool, error) {
104103
// get existing backends
105104
backends, err := action.NewCASBackendList(actionOpts).Run()
106105
if err != nil {
@@ -152,7 +151,7 @@ func captureUpdateFlags(cmd *cobra.Command) error {
152151
// handleDefaultUpdateConfirmation centralizes the confirmation logic when the --default flag
153152
// is provided. It returns (true, nil) when it's ok to proceed, (false, nil) when the user
154153
// declined confirmation, or (false, err) when an error happened.
155-
func handleDefaultUpdateConfirmation(actionOpts *options.ActionsOpts, name string) (bool, error) {
154+
func handleDefaultUpdateConfirmation(actionOpts *action.ActionsOpts, name string) (bool, error) {
156155
if isDefaultCASBackendUpdateOption == nil {
157156
return true, nil
158157
}

app/cli/cmd/options/options.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,10 @@
1616
package options
1717

1818
import (
19-
"github.com/rs/zerolog"
2019
"github.com/spf13/cobra"
21-
"google.golang.org/grpc"
2220
)
2321

2422
type Interface interface {
2523
// AddFlags adds this options' flags to the cobra command.
2624
AddFlags(cmd *cobra.Command)
2725
}
28-
29-
type ActionsOpts struct {
30-
CPConnection *grpc.ClientConn
31-
Logger zerolog.Logger
32-
AuthTokenRaw string
33-
}

app/cli/cmd/root.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import (
2727
"time"
2828

2929
"github.com/adrg/xdg"
30-
"github.com/chainloop-dev/chainloop/app/cli/cmd/options"
3130
"github.com/chainloop-dev/chainloop/app/cli/internal/action"
3231
"github.com/chainloop-dev/chainloop/app/cli/internal/telemetry"
3332
"github.com/chainloop-dev/chainloop/app/cli/internal/telemetry/posthog"
@@ -45,7 +44,7 @@ var (
4544
flagCfgFile string
4645
flagDebug bool
4746
flagOutputFormat string
48-
actionOpts *options.ActionsOpts
47+
actionOpts *action.ActionsOpts
4948
logger zerolog.Logger
5049
defaultCPAPI = "api.cp.chainloop.dev:443"
5150
defaultCASAPI = "api.cas.chainloop.dev:443"
@@ -95,7 +94,7 @@ type RootCmd struct {
9594
// in PersistentPreRunE and used across all subcommands. The double indirection
9695
// ensures that when the global actionOpts is updated (e.g., with new connection),
9796
// all references automatically point to the updated value.
98-
ActionOpts **options.ActionsOpts
97+
ActionOpts **action.ActionsOpts
9998
}
10099

101100
func NewRootCmd(l zerolog.Logger) *RootCmd {
@@ -349,8 +348,8 @@ func initConfigFile() {
349348
cobra.CheckErr(viper.ReadInConfig())
350349
}
351350

352-
func newActionOpts(logger zerolog.Logger, conn *grpc.ClientConn, token string) *options.ActionsOpts {
353-
return &options.ActionsOpts{CPConnection: conn, Logger: logger, AuthTokenRaw: token}
351+
func newActionOpts(logger zerolog.Logger, conn *grpc.ClientConn, token string) *action.ActionsOpts {
352+
return &action.ActionsOpts{CPConnection: conn, Logger: logger, AuthTokenRaw: token}
354353
}
355354

356355
func cleanup(conn *grpc.ClientConn) error {

app/cli/internal/action/action.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/chainloop-dev/chainloop/pkg/attestation/crafter"
2626
"github.com/chainloop-dev/chainloop/pkg/attestation/crafter/statemanager/filesystem"
2727
"github.com/chainloop-dev/chainloop/pkg/attestation/crafter/statemanager/remote"
28+
"github.com/rs/zerolog"
2829
"google.golang.org/grpc"
2930
)
3031

@@ -33,6 +34,12 @@ const (
3334
PolicyViolationBlockingStrategyAdvisory = "ADVISORY"
3435
)
3536

37+
type ActionsOpts struct {
38+
CPConnection *grpc.ClientConn
39+
Logger zerolog.Logger
40+
AuthTokenRaw string
41+
}
42+
3643
type OffsetPagination struct {
3744
Page int `json:"page"`
3845
PageSize int `json:"pageSize"`

app/cli/internal/action/apitoken_create.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@ import (
2121
"fmt"
2222
"time"
2323

24-
"github.com/chainloop-dev/chainloop/app/cli/cmd/options"
2524
pb "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1"
2625
"google.golang.org/protobuf/types/known/durationpb"
2726
)
2827

2928
type APITokenCreate struct {
30-
cfg *options.ActionsOpts
29+
cfg *ActionsOpts
3130
}
3231

33-
func NewAPITokenCreate(cfg *options.ActionsOpts) *APITokenCreate {
32+
func NewAPITokenCreate(cfg *ActionsOpts) *APITokenCreate {
3433
return &APITokenCreate{cfg}
3534
}
3635

app/cli/internal/action/apitoken_list.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ import (
1919
"context"
2020
"fmt"
2121

22-
"github.com/chainloop-dev/chainloop/app/cli/cmd/options"
2322
pb "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1"
2423
)
2524

2625
type APITokenList struct {
27-
cfg *options.ActionsOpts
26+
cfg *ActionsOpts
2827
}
2928

30-
func NewAPITokenList(cfg *options.ActionsOpts) *APITokenList {
29+
func NewAPITokenList(cfg *ActionsOpts) *APITokenList {
3130
return &APITokenList{cfg}
3231
}
3332

app/cli/internal/action/apitoken_revoke.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ import (
1919
"context"
2020
"fmt"
2121

22-
"github.com/chainloop-dev/chainloop/app/cli/cmd/options"
2322
pb "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1"
2423
)
2524

2625
type APITokenRevoke struct {
27-
cfg *options.ActionsOpts
26+
cfg *ActionsOpts
2827
}
2928

30-
func NewAPITokenRevoke(cfg *options.ActionsOpts) *APITokenRevoke {
29+
func NewAPITokenRevoke(cfg *ActionsOpts) *APITokenRevoke {
3130
return &APITokenRevoke{cfg}
3231
}
3332

app/cli/internal/action/artifact_download.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"path"
2626
"time"
2727

28-
"github.com/chainloop-dev/chainloop/app/cli/cmd/options"
2928
"github.com/chainloop-dev/chainloop/pkg/casclient"
3029
"github.com/jedib0t/go-pretty/v6/progress"
3130
"google.golang.org/grpc"
@@ -34,13 +33,13 @@ import (
3433
)
3534

3635
type ArtifactDownload struct {
37-
*options.ActionsOpts
36+
*ActionsOpts
3837
artifactsCASConn *grpc.ClientConn
3938
stdout io.Writer
4039
}
4140

4241
type ArtifactDownloadOpts struct {
43-
*options.ActionsOpts
42+
*ActionsOpts
4443
ArtifactsCASConn *grpc.ClientConn
4544
Stdout io.Writer
4645
}

app/cli/internal/action/artifact_upload.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"os"
2222
"time"
2323

24-
"github.com/chainloop-dev/chainloop/app/cli/cmd/options"
2524
"github.com/chainloop-dev/chainloop/pkg/casclient"
2625
"github.com/jedib0t/go-pretty/v6/progress"
2726
"google.golang.org/grpc"
@@ -32,12 +31,12 @@ type CASArtifact struct {
3231
}
3332

3433
type ArtifactUpload struct {
35-
*options.ActionsOpts
34+
*ActionsOpts
3635
artifactsCASConn *grpc.ClientConn
3736
}
3837

3938
type ArtifactUploadOpts struct {
40-
*options.ActionsOpts
39+
*ActionsOpts
4140
ArtifactsCASConn *grpc.ClientConn
4241
}
4342

app/cli/internal/action/attached_integration_add.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ import (
1919
"context"
2020
"fmt"
2121

22-
"github.com/chainloop-dev/chainloop/app/cli/cmd/options"
2322
pb "github.com/chainloop-dev/chainloop/app/controlplane/api/controlplane/v1"
2423
"google.golang.org/protobuf/types/known/structpb"
2524
)
2625

2726
// Attach a third party integration to a workflow
28-
type AttachedIntegrationAdd struct{ cfg *options.ActionsOpts }
27+
type AttachedIntegrationAdd struct{ cfg *ActionsOpts }
2928

30-
func NewAttachedIntegrationAdd(cfg *options.ActionsOpts) *AttachedIntegrationAdd {
29+
func NewAttachedIntegrationAdd(cfg *ActionsOpts) *AttachedIntegrationAdd {
3130
return &AttachedIntegrationAdd{cfg}
3231
}
3332

0 commit comments

Comments
 (0)