Skip to content

Commit 24574fd

Browse files
committed
Merge branch 'rest'
2 parents 2764747 + b7e7ae9 commit 24574fd

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

mdl/executor/cmd_rest_clients.go

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ func outputConsumedRestServiceMDL(ctx *ExecContext, svc *model.ConsumedRestServi
120120
if svc.Authentication == nil {
121121
fmt.Fprintln(w, " Authentication: NONE")
122122
} else {
123-
username := formatRestAuthValue(svc.Authentication.Username)
124-
password := formatRestAuthValue(svc.Authentication.Password)
123+
username := resolveAndFormatRestAuthValue(ctx, svc.Authentication.Username)
124+
password := resolveAndFormatRestAuthValue(ctx, svc.Authentication.Password)
125125
fmt.Fprintf(w, " Authentication: BASIC (Username: %s, Password: %s)\n",
126126
username, password)
127127
}
@@ -555,4 +555,31 @@ func formatRestAuthValue(value string) string {
555555
return "'" + value + "'"
556556
}
557557

558+
// resolveAndFormatRestAuthValue resolves a constant reference to its literal DefaultValue
559+
// for DESCRIBE output. Falls back to @Module.Constant notation when resolution fails.
560+
func resolveAndFormatRestAuthValue(ctx *ExecContext, value string) string {
561+
if !strings.HasPrefix(value, "$") {
562+
return "'" + value + "'"
563+
}
564+
qualifiedName := strings.TrimPrefix(value, "$")
565+
if ctx != nil && ctx.Backend != nil {
566+
parts := strings.SplitN(qualifiedName, ".", 2)
567+
if len(parts) == 2 {
568+
moduleName, constName := parts[0], parts[1]
569+
if constants, err := ctx.Backend.ListConstants(); err == nil {
570+
for _, c := range constants {
571+
if !strings.EqualFold(c.Name, constName) {
572+
continue
573+
}
574+
if mod, err := ctx.Backend.GetModule(c.ContainerID); err == nil &&
575+
strings.EqualFold(mod.Name, moduleName) {
576+
return "'" + c.DefaultValue + "'"
577+
}
578+
}
579+
}
580+
}
581+
}
582+
return "@" + qualifiedName
583+
}
584+
558585
// Executor wrappers for unmigrated callers.

0 commit comments

Comments
 (0)