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

Function NewCASClientUseCase

app/controlplane/pkg/biz/casclient.go:71–103  ·  view source on GitHub ↗
(credsProvider *CASCredentialsUseCase, config *conf.Bootstrap_CASServer, l log.Logger, opts ...CASClientOpts)

Source from the content-addressed store, hash-verified

69}
70
71func NewCASClientUseCase(credsProvider *CASCredentialsUseCase, config *conf.Bootstrap_CASServer, l log.Logger, opts ...CASClientOpts) *CASClientUseCase {
72 helper := servicelogger.ScopedHelper(l, "biz/cas-client")
73
74 // generate a client from the given configuration
75 defaultCasClientFactory := func(conf *conf.Bootstrap_CASServer, token string) (casclient.DownloaderUploader, func(), error) {
76 conn, err := grpcconn.New(conf.GetGrpc().GetAddr(), token, grpcconn.WithInsecure(conf.GetInsecure()))
77 if err != nil {
78 return nil, nil, fmt.Errorf("failed to create grpc connection: %w", err)
79 }
80
81 closerFn := func() {
82 err := conn.Close()
83 if err != nil {
84 helper.Error(err)
85 }
86 }
87
88 return casclient.New(conn), closerFn, err
89 }
90
91 uc := &CASClientUseCase{
92 credsProvider: credsProvider,
93 casServerConf: config,
94 logger: helper,
95 casClientFactory: defaultCasClientFactory,
96 }
97
98 for _, opt := range opts {
99 opt(uc)
100 }
101
102 return uc
103}
104
105// The secretID is embedded in the JWT token and is used to identify the secret by the CAS server
106func (uc *CASClientUseCase) Upload(ctx context.Context, backendType, secretID string, orgID uuid.UUID, content io.Reader, filename, digest string) error {

Callers 2

TestIsReadyFunction · 0.92
wireAppFunction · 0.92

Calls 9

ScopedHelperFunction · 0.92
NewFunction · 0.92
WithInsecureFunction · 0.92
NewFunction · 0.92
ErrorMethod · 0.65
GetAddrMethod · 0.45
GetGrpcMethod · 0.45
GetInsecureMethod · 0.45
CloseMethod · 0.45

Tested by 1

TestIsReadyFunction · 0.74