MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / newCrafter

Function newCrafter

app/cli/pkg/action/action.go:83–114  ·  view source on GitHub ↗
(stateOpts *newCrafterStateOpts, conn *grpc.ClientConn, opts ...crafter.NewOpt)

Source from the content-addressed store, hash-verified

81}
82
83func newCrafter(stateOpts *newCrafterStateOpts, conn *grpc.ClientConn, opts ...crafter.NewOpt) (*crafter.Crafter, error) {
84 var stateManager crafter.StateManager
85 var err error
86
87 if stateOpts == nil {
88 return nil, fmt.Errorf("missing state manager options")
89 }
90
91 // run opts to extract logger
92 c := &crafter.Crafter{}
93 for _, opt := range opts {
94 _ = opt(c)
95 }
96
97 switch stateOpts.enableRemoteState {
98 case true:
99 stateManager, err = remote.New(pb.NewAttestationStateServiceClient(conn), c.Logger)
100 case false:
101 attestationStatePath := AttestationStatePath(stateOpts.localStatePath)
102
103 c.Logger.Debug().Str("path", fmt.Sprintf("file:%s", attestationStatePath)).Msg("using local state")
104 stateManager, err = filesystem.New(attestationStatePath)
105 }
106
107 if err != nil {
108 return nil, fmt.Errorf("failed to create state manager: %w", err)
109 }
110
111 attClient := pb.NewAttestationServiceClient(conn)
112
113 return crafter.NewCrafter(stateManager, attClient, opts...)
114}
115
116// getCASBackend tries to get CAS upload credentials and set up a CAS client
117func getCASBackend(ctx context.Context, client pb.AttestationServiceClient, workflowRunID, casCAPath, casURI string, casConnectionInsecure bool, logger zerolog.Logger, casBackend *casclient.CASBackend, cliVersion string) (*clientAPI.Attestation_CASBackend, func() error, error) {

Callers 6

RunMethod · 0.85
NewAttestationStatusFunction · 0.85
RunMethod · 0.85
NewAttestationInitFunction · 0.85
RunMethod · 0.85
GetPolicyEvaluationsMethod · 0.85

Calls 5

NewFunction · 0.92
NewFunction · 0.92
NewCrafterFunction · 0.92
AttestationStatePathFunction · 0.85
DebugMethod · 0.45

Tested by

no test coverage detected