@@ -318,36 +318,21 @@ func (s *AttestationService) GetUploadCreds(ctx context.Context, req *cpAPI.Atte
318318
319319 // Find the CAS backend associated with this workflowRun, that's the one that will be used to upload the materials
320320 // NOTE: currently we only support one backend per workflowRun but this will change in the future
321+ // This is the new mode, where the CAS backend ref is stored in the workflow run since initialization
322+ wRun , err := s .wrUseCase .GetByIDInOrgOrPublic (ctx , robotAccount .OrgID , req .WorkflowRunId )
323+ if err != nil {
324+ return nil , handleUseCaseErr (err , s .log )
325+ } else if wRun == nil {
326+ return nil , errors .NotFound ("not found" , "workflow run not found" )
327+ }
321328
322- // DEPRECATED: if no workflow run is provided, we use the default repository
323- // Maintained for compatibility reasons with older versions of the CLI
324- var backend * biz.CASBackend
325- if req .WorkflowRunId == "" {
326- s .log .Warn ("DEPRECATED: using main repository to get upload creds" )
327- backend , err := s .casUC .FindDefaultBackend (ctx , robotAccount .OrgID )
328- if err != nil && ! biz .IsNotFound (err ) {
329- return nil , handleUseCaseErr (err , s .log )
330- } else if backend == nil {
331- return nil , errors .NotFound ("not found" , "main repository not found" )
332- }
333- } else {
334- // This is the new mode, where the CAS backend ref is stored in the workflow run since initialization
335- wRun , err := s .wrUseCase .GetByIDInOrgOrPublic (ctx , robotAccount .OrgID , req .WorkflowRunId )
336- if err != nil {
337- return nil , handleUseCaseErr (err , s .log )
338- } else if wRun == nil {
339- return nil , errors .NotFound ("not found" , "workflow run not found" )
340- }
341-
342- if len (wRun .CASBackends ) == 0 {
343- return nil , errors .NotFound ("not found" , "workflow run has no CAS backend" )
344- }
345-
346- s .log .Infow ("msg" , "generating upload credentials for CAS backend" , "ID" , wRun .CASBackends [0 ].ID , "name" , wRun .CASBackends [0 ].Location , "workflowRun" , req .WorkflowRunId )
347-
348- backend = wRun .CASBackends [0 ]
329+ if len (wRun .CASBackends ) == 0 {
330+ return nil , errors .NotFound ("not found" , "workflow run has no CAS backend" )
349331 }
350332
333+ backend := wRun .CASBackends [0 ]
334+ s .log .Infow ("msg" , "generating upload credentials for CAS backend" , "ID" , wRun .CASBackends [0 ].ID , "name" , wRun .CASBackends [0 ].Location , "workflowRun" , req .WorkflowRunId )
335+
351336 // Return the backend information and associated credentials (if applicable)
352337 resp := & cpAPI.AttestationServiceGetUploadCredsResponse_Result {Backend : bizCASBackendToPb (backend )}
353338 if backend .SecretName != "" {
0 commit comments