forked from kluctl/kluctl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_poke_images.go
60 lines (54 loc) · 1.55 KB
/
cmd_poke_images.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package commands
import (
"fmt"
"github.com/codablock/kluctl/cmd/kluctl/args"
"github.com/codablock/kluctl/pkg/deployment/commands"
"github.com/codablock/kluctl/pkg/utils"
)
type pokeImagesCmd struct {
args.ProjectFlags
args.TargetFlags
args.ArgsFlags
args.ImageFlags
args.InclusionFlags
args.YesFlags
args.DryRunFlags
args.OutputFlags
args.RenderOutputDirFlags
}
func (cmd *pokeImagesCmd) Help() string {
return `This command will fully render the target and then only replace images instead of fully
deploying the target. Only images used in combination with 'images.get_image(...)' are
replaced`
}
func (cmd *pokeImagesCmd) Run() error {
ptArgs := projectTargetCommandArgs{
projectFlags: cmd.ProjectFlags,
targetFlags: cmd.TargetFlags,
argsFlags: cmd.ArgsFlags,
imageFlags: cmd.ImageFlags,
inclusionFlags: cmd.InclusionFlags,
dryRunArgs: &cmd.DryRunFlags,
renderOutputDirFlags: cmd.RenderOutputDirFlags,
}
return withProjectCommandContext(ptArgs, func(ctx *commandCtx) error {
if !cmd.Yes && !cmd.DryRun {
if !utils.AskForConfirmation(fmt.Sprintf("Do you really want to poke images to the context/cluster %s?", ctx.k.Context())) {
return fmt.Errorf("aborted")
}
}
cmd2 := commands.NewPokeImagesCommand(ctx.deploymentCollection)
result, err := cmd2.Run(ctx.k)
if err != nil {
return err
}
err = outputCommandResult(cmd.Output, result)
if err != nil {
return err
}
if len(result.Errors) != 0 {
return fmt.Errorf("command failed")
}
return nil
})
}