From 4b91ddf1f5013957ac92a427557e2103e8e6ada9 Mon Sep 17 00:00:00 2001 From: Ariel Mashraki Date: Wed, 31 Jan 2024 09:43:34 +0200 Subject: [PATCH] cmd/atlas: allow ref env:// to known attributes --- cmd/atlas/internal/cmdapi/project.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/cmd/atlas/internal/cmdapi/project.go b/cmd/atlas/internal/cmdapi/project.go index ea130911bc4..282696c2d65 100644 --- a/cmd/atlas/internal/cmdapi/project.go +++ b/cmd/atlas/internal/cmdapi/project.go @@ -175,13 +175,20 @@ func (e *Env) VarFromURL(s string) (string, error) { if u.Host == "" || u.Path != "" || u.RawQuery != "" { return "", fmt.Errorf("invalid env:// variable %q", s) } - attr, ok := e.Attr(u.Host) - if !ok { - return "", fmt.Errorf("env://%s (attribute) not found in env.%s", s, e.Name) - } - sv, err := attr.String() - if err != nil { - return "", fmt.Errorf("env://%s: %w", s, err) + var sv string + switch u.Host { + case "url": + sv = e.URL + case "dev": + sv = e.DevURL + default: + attr, ok := e.Attr(u.Host) + if !ok { + return "", fmt.Errorf("env://%s (attribute) not found in env.%s", u.Host, e.Name) + } + if sv, err = attr.String(); err != nil { + return "", fmt.Errorf("env://%s: %w", u.Host, err) + } } if strings.HasPrefix(sv, envAttrScheme+"://") { return "", fmt.Errorf("env://%s (attribute) cannot reference another env://", s)