grim/convey
Clone
Summary
Browse
Changes
Graph
Add the podman/remove task and unit tests for it
redux
2021-10-11, Gary Kramlich
1ca9512295a0
Add the podman/remove task and unit tests for it
package
environment
import
(
"os"
)
func
(
e
Environment
)
expandMapper
(
name
string
)
string
{
// We might have something like $(pwd), in which case we don't want
// to wrap the name in `{}`, which would cause it to be ${}(pwd) and
// cannot be evaluated by a run task.
if
name
==
""
{
return
"$"
}
if
val
,
found
:=
e
[
name
];
found
{
if
val
!=
""
{
return
val
}
return
os
.
Getenv
(
name
)
}
return
""
}
// Expand looks for the given key and returns the value if one is found
// recursing if the value contains another variable.
func
(
e
Environment
)
Expand
(
key
string
)
string
{
return
os
.
Expand
(
key
,
e
.
expandMapper
)
}
func
(
e
Environment
)
Expandv
(
items
[]
string
)
[]
string
{
expanded
:=
make
([]
string
,
len
(
items
))
for
idx
,
item
:=
range
items
{
expanded
[
idx
]
=
e
.
Expand
(
item
)
}
return
expanded
}