Skip to content

Commit 3a48028

Browse files
authored
chore: Fix lint & revert some changes to get test suite passing (#180)
* fix: Lint error * chore: Revert previous implementation to get tests passing * chore: Revert credentials config & credentials changes * fix: Manual destawssqs endpoint validation
1 parent 27021f7 commit 3a48028

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

internal/destregistry/baseprovider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
// - 10 or more characters: show first 4 characters + asterisks for the rest
1717
func ObfuscateValue(value string) string {
1818
if len(value) < 10 {
19-
return strings.Repeat("*", len(value))
19+
return "****"
2020
}
2121
return value[:4] + strings.Repeat("*", len(value)-4)
2222
}

internal/destregistry/providers/destawssqs/destawssqs.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ func (d *AWSSQSDestination) resolveMetadata(ctx context.Context, destination *mo
100100
return nil, nil, err
101101
}
102102

103+
if endpoint := destination.Config["endpoint"]; endpoint != "" {
104+
parsedURL, err := url.Parse(endpoint)
105+
if err != nil || !parsedURL.IsAbs() || (parsedURL.Scheme != "http" && parsedURL.Scheme != "https") {
106+
return nil, nil, destregistry.NewErrDestinationValidation([]destregistry.ValidationErrorDetail{
107+
{
108+
Field: "config.endpoint",
109+
Type: "pattern",
110+
},
111+
})
112+
}
113+
}
114+
103115
return &AWSSQSDestinationConfig{
104116
Endpoint: destination.Config["endpoint"],
105117
QueueURL: destination.Config["queue_url"],

internal/services/api/destination_handlers.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,11 @@ func (h *DestinationHandlers) Update(c *gin.Context) {
158158
}
159159
if input.Config != nil {
160160
shouldRevalidate = true
161-
updatedDestination.Config = mergeStringMaps(originalDestination.Config, input.Config)
161+
updatedDestination.Config = input.Config
162162
}
163163
if input.Credentials != nil {
164164
shouldRevalidate = true
165-
updatedDestination.Credentials = mergeStringMaps(originalDestination.Credentials, input.Credentials)
165+
updatedDestination.Credentials = input.Credentials
166166
}
167167
if shouldRevalidate {
168168
if err := h.registry.ValidateDestination(c.Request.Context(), &updatedDestination); err != nil {
@@ -338,17 +338,6 @@ type UpdateDestinationRequest struct {
338338
Credentials models.Credentials `json:"credentials" binding:"-"`
339339
}
340340

341-
func mergeStringMaps(original, input map[string]string) map[string]string {
342-
merged := make(map[string]string)
343-
for k, v := range original {
344-
merged[k] = v
345-
}
346-
for k, v := range input {
347-
merged[k] = v
348-
}
349-
return merged
350-
}
351-
352341
func mustRoleFromContext(c *gin.Context) string {
353342
if role, exists := c.Get(authRoleKey); exists {
354343
if roleStr, ok := role.(string); ok {

internal/services/api/router.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type routeDefinition struct {
5959
}
6060

6161
// registerRoutes registers routes to the given router based on route definitions and config
62-
func registerRoutes(router *gin.RouterGroup, cfg RouterConfig, routes []RouteDefinition, logger *otelzap.Logger, entityStore models.EntityStore) {
62+
func registerRoutes(router *gin.RouterGroup, cfg RouterConfig, routes []RouteDefinition) {
6363
isPortalMode := cfg.APIKey != "" && cfg.JWTSecret != ""
6464

6565
for _, route := range routes {
@@ -381,7 +381,7 @@ func NewRouter(
381381
apiRoutes = append(apiRoutes, tenantAgnosticRoutes...)
382382
apiRoutes = append(apiRoutes, tenantSpecificRoutes...)
383383

384-
registerRoutes(apiRouter, cfg, apiRoutes, logger, entityStore)
384+
registerRoutes(apiRouter, cfg, apiRoutes)
385385

386386
return r
387387
}

0 commit comments

Comments
 (0)