Skip to content

Commit edeec2f

Browse files
committed
add skip-refresh dartboard argument for tofu.Apply()
1 parent ca25b09 commit edeec2f

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

cmd/dartboard/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ func main() {
6363
Usage: "skip 'helm install' for all charts, assume charts have already been installed for upstream and tester clusters",
6464
DefaultText: "false",
6565
},
66+
&cli.BoolFlag{
67+
Name: subcommands.ArgSkipRefresh,
68+
Value: false,
69+
Usage: "skip refresh phase for tofu resources, assume resources are refreshed and up-to-date",
70+
DefaultText: "false",
71+
},
6672
},
6773
},
6874
{

cmd/dartboard/subcommands/apply.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ func Apply(cli *cli.Context) error {
2727
if err = tf.PrintVersion(); err != nil {
2828
return err
2929
}
30-
if err = tf.Apply(); err != nil {
30+
31+
skipRefresh := cli.Bool(ArgSkipRefresh)
32+
33+
if err = tf.Apply(skipRefresh); err != nil {
3134
return err
3235
}
3336

cmd/dartboard/subcommands/deploy.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@ func Deploy(cli *cli.Context) error {
5353
return err
5454
}
5555

56+
skipRefresh := cli.Bool(ArgSkipRefresh)
57+
5658
if !cli.Bool(ArgSkipApply) {
5759
if err = tf.PrintVersion(); err != nil {
5860
return err
5961
}
60-
if err = tf.Apply(); err != nil {
62+
if err = tf.Apply(skipRefresh); err != nil {
6163
return err
6264
}
6365
} else {

cmd/dartboard/subcommands/utils.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ import (
3131
)
3232

3333
const (
34-
ArgDart = "dart"
35-
ArgSkipApply = "skip-apply"
36-
ArgSkipCharts = "skip-charts"
34+
ArgDart = "dart"
35+
ArgSkipApply = "skip-apply"
36+
ArgSkipCharts = "skip-charts"
37+
ArgSkipRefresh = "skip-refresh"
3738
)
3839

3940
type clusterAddress struct {

internal/tofu/tofu.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,18 @@ func (t *Tofu) newWorkspace() error {
220220
return t.exec(nil, args...)
221221
}
222222

223-
func (t *Tofu) Apply() error {
223+
func (t *Tofu) Apply(skipRefresh bool) error {
224224
err := t.handleWorkspace()
225225
if err != nil {
226226
return err
227227
}
228228

229229
args := t.commonArgs("apply")
230230

231+
if skipRefresh {
232+
args = append(args, "-refresh=false")
233+
}
234+
231235
return t.exec(nil, args...)
232236
}
233237

0 commit comments

Comments
 (0)