grim/convey
Clone
Summary
Browse
Changes
Graph
Use the logger for info/warning messages at startup
redux
2021-10-11, Gary Kramlich
466f881e1593
Use the logger for info/warning messages at startup
package
podman
import
(
"fmt"
"strings"
log
"github.com/sirupsen/logrus"
"keep.imfreedom.org/grim/convey/environment"
"keep.imfreedom.org/grim/convey/exec"
"keep.imfreedom.org/grim/convey/runtime"
"keep.imfreedom.org/grim/convey/tasks"
"keep.imfreedom.org/grim/convey/yaml"
)
type
Remove
struct
{
Tags
yaml
.
StringOrSlice
`yaml:"tags"`
Quiet
bool
`yaml:"quiet"`
}
func
(
r
*
Remove
)
Execute
(
name
string
,
logger
*
log
.
Entry
,
stageEnv
environment
.
Environment
,
rt
*
runtime
.
Runtime
)
error
{
env
:=
stageEnv
.
Copy
().
Merge
(
rt
.
Environment
)
tags
:=
env
.
Expandv
(
r
.
Tags
)
for
_
,
tag
:=
range
tags
{
generator
:=
exec
.
NewGenerator
(
"podman"
,
"rmi"
,
tag
,
)
_
,
stderr
,
err
:=
exec
.
RunOutput
(
name
,
generator
.
Command
(),
rt
.
Timeout
)
if
err
!=
nil
{
if
r
.
Quiet
&&
strings
.
Contains
(
stderr
,
"image not known"
)
{
continue
}
return
fmt
.
Errorf
(
"%s"
,
strings
.
TrimSpace
(
stderr
))
}
}
return
nil
}
func
(
r
*
Remove
)
New
()
tasks
.
Task
{
return
&
Remove
{}
}
func
(
r
*
Remove
)
Valid
()
error
{
if
len
(
r
.
Tags
)
==
0
{
return
ErrNoTags
}
return
nil
}
func
(
r
*
Remove
)
Deprecated
()
error
{
return
nil
}