From bb06c339749c5e24daad9dab47eb1a48527fee44 Mon Sep 17 00:00:00 2001 From: dani <29378233+kheina@users.noreply.github.com> Date: Wed, 19 Mar 2025 11:36:22 -0400 Subject: [PATCH] update loopback to normalize endpoint_url (#5603) --- internal/host/plugin/repository_host_catalog.go | 1 + internal/plugin/loopback/storage.go | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/host/plugin/repository_host_catalog.go b/internal/host/plugin/repository_host_catalog.go index 109484338b..028dfb38b0 100644 --- a/internal/host/plugin/repository_host_catalog.go +++ b/internal/host/plugin/repository_host_catalog.go @@ -51,6 +51,7 @@ func normalizeCatalogAttributes(ctx context.Context, plgClient plgpb.HostPluginS }) switch { case err == nil: + // TODO: this should be updated to return these attributes rather than updating them in-place if ret.Attributes != nil { plgHc.Attrs = &pb.HostCatalog_Attributes{ Attributes: ret.Attributes, diff --git a/internal/plugin/loopback/storage.go b/internal/plugin/loopback/storage.go index e588933759..cd16dbe178 100644 --- a/internal/plugin/loopback/storage.go +++ b/internal/plugin/loopback/storage.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/storagebuckets" plgpb "github.com/hashicorp/boundary/sdk/pbs/plugin" + "github.com/hashicorp/go-secure-stdlib/parseutil" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/structpb" @@ -141,9 +142,15 @@ func (l *LoopbackStorage) normalizeStorageBucketData(ctx context.Context, req *p if req.GetAttributes() == nil { return nil, status.Errorf(codes.InvalidArgument, "%s: missing attributes", op) } + attrs := req.GetAttributes() + if endpoint, ok := attrs.GetFields()["endpoint_url"]; ok { + if endpoint, err := parseutil.NormalizeAddr(endpoint.GetStringValue()); err == nil { + attrs.Fields["endpoint_url"] = structpb.NewStringValue(endpoint) + } + } l.normalizations++ return &plgpb.NormalizeStorageBucketDataResponse{ - Attributes: req.GetAttributes(), + Attributes: attrs, }, nil }