Skip to content

Commit 12a2d21

Browse files
committed
alpha: simplify resource skipping
1 parent aae6b57 commit 12a2d21

File tree

5 files changed

+14
-22
lines changed

5 files changed

+14
-22
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/mholt/archiver/v3 v3.5.1
1616
github.com/mitchellh/go-homedir v1.1.0
1717
github.com/otiai10/copy v1.6.0
18-
github.com/outblocks/outblocks-plugin-go v0.0.0-20211106144905-90f0e0506308
18+
github.com/outblocks/outblocks-plugin-go v0.0.0-20211106234251-c71bad7aa25c
1919
github.com/pterm/pterm v0.12.33
2020
github.com/spf13/cobra v1.2.1
2121
github.com/spf13/pflag v1.0.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,8 +681,8 @@ github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6
681681
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
682682
github.com/otiai10/mint v1.3.2 h1:VYWnrP5fXmz1MXvjuUvcBrXSjGE6xjON+axB/UrpO3E=
683683
github.com/otiai10/mint v1.3.2/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
684-
github.com/outblocks/outblocks-plugin-go v0.0.0-20211106144905-90f0e0506308 h1:UW2KpHVY34EmPCuY0z1NvOmkEAooIWzqKiS6B1ML654=
685-
github.com/outblocks/outblocks-plugin-go v0.0.0-20211106144905-90f0e0506308/go.mod h1:xosanOIc+3GlRA9b90/xRoYWzRgdhbew9T7+yTeI/TQ=
684+
github.com/outblocks/outblocks-plugin-go v0.0.0-20211106234251-c71bad7aa25c h1:fRasRVoXHmFLlcagcE/6SHQM8lcaf5t96gphICbvBKw=
685+
github.com/outblocks/outblocks-plugin-go v0.0.0-20211106234251-c71bad7aa25c/go.mod h1:xosanOIc+3GlRA9b90/xRoYWzRgdhbew9T7+yTeI/TQ=
686686
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
687687
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
688688
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=

pkg/actions/deploy.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ import (
2525
const deployCommand = "deploy"
2626

2727
type planParams struct {
28-
apps []*types.AppPlan
29-
deps []*types.DependencyPlan
30-
targetApps, skipApps []string
31-
args map[string]interface{}
32-
firstPass bool
28+
apps []*types.AppPlan
29+
deps []*types.DependencyPlan
30+
args map[string]interface{}
31+
firstPass bool
3332
}
3433

3534
type Deploy struct {
@@ -468,12 +467,9 @@ func addPlanTargetAndSkipApps(planMap map[*plugins.Plugin]*planParams, targetApp
468467

469468
for _, planParam := range planMap {
470469
for _, app := range planParam.apps {
471-
if targetAppIDsMap[app.App.ID] {
472-
planParam.targetApps = append(planParam.targetApps, app.App.ID)
473-
}
470+
if skipAppIDsMap[app.App.ID] || (len(targetAppIDsMap) > 0 && !targetAppIDsMap[app.App.ID]) {
471+
app.Skip = true
474472

475-
if skipAppIDsMap[app.App.ID] {
476-
planParam.skipApps = append(planParam.skipApps, app.App.ID)
477473
}
478474
}
479475
}
@@ -496,7 +492,7 @@ func plan(ctx context.Context, state *types.StateData, planMap map[*plugins.Plug
496492
params := params
497493

498494
g.Go(func() error {
499-
ret, err := plug.Client().Plan(ctx, state, params.apps, params.deps, params.targetApps, params.skipApps, params.args, verify, destroy)
495+
ret, err := plug.Client().Plan(ctx, state, params.apps, params.deps, params.args, verify, destroy)
500496
if err != nil {
501497
return err
502498
}
@@ -568,7 +564,7 @@ func apply(ctx context.Context, state *types.StateData, planMap map[*plugins.Plu
568564
}
569565

570566
g.Go(func() error {
571-
ret, err := plug.Client().Apply(ctx, state, params.apps, params.deps, params.targetApps, params.skipApps, params.args, destroy, callback)
567+
ret, err := plug.Client().Apply(ctx, state, params.apps, params.deps, params.args, destroy, callback)
572568
processResponse(plug, ret)
573569

574570
return err
@@ -589,7 +585,7 @@ func apply(ctx context.Context, state *types.StateData, planMap map[*plugins.Plu
589585
}
590586

591587
g.Go(func() error {
592-
ret, err := plug.Client().Apply(ctx, state, params.apps, params.deps, params.targetApps, params.skipApps, params.args, destroy, callback)
588+
ret, err := plug.Client().Apply(ctx, state, params.apps, params.deps, params.args, destroy, callback)
593589
processResponse(plug, ret)
594590

595591
return err

pkg/plugins/client/apply.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ import (
77
"github.com/outblocks/outblocks-plugin-go/types"
88
)
99

10-
func (c *Client) Apply(ctx context.Context, state *types.StateData, apps []*types.AppPlan, deps []*types.DependencyPlan, targetApps, skipApps []string, args map[string]interface{}, destroy bool, callback func(*types.ApplyAction)) (ret *plugin_go.ApplyDoneResponse, err error) {
10+
func (c *Client) Apply(ctx context.Context, state *types.StateData, apps []*types.AppPlan, deps []*types.DependencyPlan, args map[string]interface{}, destroy bool, callback func(*types.ApplyAction)) (ret *plugin_go.ApplyDoneResponse, err error) {
1111
stream, err := c.lazyStartBiDi(ctx, &plugin_go.ApplyRequest{
1212
DeployBaseRequest: plugin_go.DeployBaseRequest{
1313
Apps: apps,
1414
Dependencies: deps,
15-
TargetApps: targetApps,
16-
SkipApps: skipApps,
1715
Args: args,
1816

1917
StateMap: state.PluginsMap[c.name],

pkg/plugins/client/plan.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ import (
88
"github.com/outblocks/outblocks-plugin-go/types"
99
)
1010

11-
func (c *Client) Plan(ctx context.Context, state *types.StateData, apps []*types.AppPlan, deps []*types.DependencyPlan, targetApps, skipApps []string, args map[string]interface{}, verify, destroy bool) (ret *plugin_go.PlanResponse, err error) {
11+
func (c *Client) Plan(ctx context.Context, state *types.StateData, apps []*types.AppPlan, deps []*types.DependencyPlan, args map[string]interface{}, verify, destroy bool) (ret *plugin_go.PlanResponse, err error) {
1212
err = c.lazySendReceive(ctx, &plugin_go.PlanRequest{
1313
DeployBaseRequest: plugin_go.DeployBaseRequest{
1414
Apps: apps,
1515
Dependencies: deps,
16-
TargetApps: targetApps,
17-
SkipApps: skipApps,
1816
Args: args,
1917

2018
StateMap: state.PluginsMap[c.name],

0 commit comments

Comments
 (0)