(cpConn *grpc.ClientConn, role pb.CASCredentialsServiceGetRequest_Role, digest string)
| 37 | } |
| 38 | |
| 39 | func wrappedArtifactConn(cpConn *grpc.ClientConn, role pb.CASCredentialsServiceGetRequest_Role, digest string) (*grpc.ClientConn, error) { |
| 40 | // Retrieve temporary credentials for uploading |
| 41 | client := pb.NewCASCredentialsServiceClient(cpConn) |
| 42 | resp, err := client.Get(context.Background(), &pb.CASCredentialsServiceGetRequest{ |
| 43 | Role: role, |
| 44 | Digest: digest, |
| 45 | }) |
| 46 | if err != nil { |
| 47 | return nil, err |
| 48 | } |
| 49 | |
| 50 | if apiInsecure() { |
| 51 | logger.Warn().Msg("API contacted in insecure mode") |
| 52 | } |
| 53 | |
| 54 | var opts = []grpcconn.Option{ |
| 55 | grpcconn.WithInsecure(apiInsecure()), |
| 56 | grpcconn.WithCLIVersion(fullVersion()), |
| 57 | } |
| 58 | |
| 59 | if maxRecv := apiMaxRecvMsgSize(); maxRecv > 0 { |
| 60 | opts = append(opts, grpcconn.WithMaxRecvMsgSize(maxRecv)) |
| 61 | } |
| 62 | |
| 63 | if caValue := viper.GetString(confOptions.CASCA.viperKey); caValue != "" { |
| 64 | if _, err := os.Stat(caValue); err == nil { |
| 65 | opts = append(opts, grpcconn.WithCAFile(caValue)) |
| 66 | } else { |
| 67 | opts = append(opts, grpcconn.WithCAContent(caValue)) |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | return grpcconn.New(viper.GetString(confOptions.CASAPI.viperKey), resp.Result.Token, opts...) |
| 72 | } |
no test coverage detected