|
|
@@ -95,7 +95,6 @@ func (c *RegistryGetECRTokenHandler) ServeHTTP(w http.ResponseWriter, r *http.Re
|
|
|
// if the aws integration doesn't have an ARN populated, populate it
|
|
|
if awsInt.AWSArn == "" {
|
|
|
err = awsInt.PopulateAWSArn()
|
|
|
-
|
|
|
if err != nil {
|
|
|
continue
|
|
|
}
|
|
|
@@ -230,9 +229,13 @@ func (c *RegistryGetGARTokenHandler) ServeHTTP(w http.ResponseWriter, r *http.Re
|
|
|
request := &types.GetRegistryGCRTokenRequest{}
|
|
|
|
|
|
if ok := c.DecodeAndValidate(w, r, request); !ok {
|
|
|
+ err := telemetry.Error(ctx, span, nil, "error decoding request")
|
|
|
+ c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(err, http.StatusBadRequest))
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ telemetry.WithAttributes(span, telemetry.AttributeKV{Key: "server-url", Value: request.ServerURL})
|
|
|
+
|
|
|
// list registries and find one that matches the region
|
|
|
regs, err := c.Repo().Registry().ListRegistriesByProjectID(proj.ID)
|
|
|
if err != nil {
|
|
|
@@ -251,18 +254,29 @@ func (c *RegistryGetGARTokenHandler) ServeHTTP(w http.ResponseWriter, r *http.Re
|
|
|
var registryURL string
|
|
|
|
|
|
for _, reg := range regs {
|
|
|
- if strings.Contains(reg.URL, "-docker.pkg.dev") {
|
|
|
+ if strings.Contains(reg.URL, request.ServerURL) {
|
|
|
registryURL = reg.URL
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if registryURL == "" {
|
|
|
- e := telemetry.Error(ctx, span, err, "no matching registry found")
|
|
|
- c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(e, http.StatusNotFound))
|
|
|
- return
|
|
|
+ for _, reg := range regs {
|
|
|
+ if strings.Contains(reg.URL, "-docker.pkg.dev") {
|
|
|
+ registryURL = reg.URL
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if registryURL == "" {
|
|
|
+ e := telemetry.Error(ctx, span, err, "no matching registry found")
|
|
|
+ c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(e, http.StatusNotFound))
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ telemetry.WithAttributes(span, telemetry.AttributeKV{Key: "registry-url", Value: registryURL})
|
|
|
+
|
|
|
regInput := connect.NewRequest(&porterv1.TokenForRegistryRequest{
|
|
|
ProjectId: int64(proj.ID),
|
|
|
RegistryUri: registryURL,
|