Skip to content

Commit 2686669

Browse files
authored
Simplify action name "update(id_stable)" -> "update" (#3661)
## Changes - "update(id_stable)" becomes "update" - "update(id_changes)" becomes "update_id" - StringFull() becomes String() ## Why This names show up in JSON plan and "update" is most common action, so seeing "update(id_stable)" feels like unnecessary noise.
1 parent bc9bd02 commit 2686669

File tree

7 files changed

+15
-23
lines changed

7 files changed

+15
-23
lines changed

acceptance/bundle/resources/jobs/update/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged
7575
{
7676
"plan": {
7777
"resources.jobs.foo": {
78-
"action": "update(id_stable)"
78+
"action": "update"
7979
}
8080
}
8181
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"plan": {
33
"resources.volumes.volume1": {
4-
"action": "update(id_changes)"
4+
"action": "update_id"
55
}
66
}
77
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"plan": {
33
"resources.volumes.volume1": {
4-
"action": "update(id_stable)"
4+
"action": "update"
55
}
66
}
77
}

bundle/deploy/terraform/showplanfile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func populatePlan(ctx context.Context, plan *deployplan.Plan, changes []*tfjson.
4747
}
4848

4949
key := "resources." + group + "." + rc.Name
50-
plan.Plan[key] = deployplan.PlanEntry{Action: actionType.StringFull()}
50+
plan.Plan[key] = deployplan.PlanEntry{Action: actionType.String()}
5151
}
5252
}
5353

bundle/deployplan/action.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ const (
4343
var actionName = map[ActionType]string{
4444
ActionTypeNoop: "noop",
4545
ActionTypeResize: "resize",
46-
ActionTypeUpdate: "update(id_stable)",
47-
ActionTypeUpdateWithID: "update(id_changes)",
46+
ActionTypeUpdate: "update",
47+
ActionTypeUpdateWithID: "update_id",
4848
ActionTypeCreate: "create",
4949
ActionTypeRecreate: "recreate",
5050
ActionTypeDelete: "delete",
@@ -74,14 +74,14 @@ func (a ActionType) KeepsID() bool {
7474
}
7575
}
7676

77-
// StringShort short version of action string, without part in parens.
77+
// StringShort short version of action string, without suffix
7878
func (a ActionType) StringShort() string {
79-
items := strings.SplitN(actionName[a], "(", 2)
79+
items := strings.SplitN(actionName[a], "_", 2)
8080
return items[0]
8181
}
8282

83-
// StringFull returns the string representation of the action type.
84-
func (a ActionType) StringFull() string {
83+
// String returns the string representation of the action type.
84+
func (a ActionType) String() string {
8585
return actionName[a]
8686
}
8787

bundle/deployplan/action_test.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package deployplan
22

33
import (
4-
"fmt"
54
"maps"
65
"slices"
76
"strings"
@@ -18,7 +17,7 @@ func TestStringShort(t *testing.T) {
1817

1918
for _, a := range keys {
2019
s := actionName[a]
21-
require.Equal(t, a.StringFull(), s)
20+
require.Equal(t, a.String(), s)
2221
short := a.StringShort()
2322
require.NotEmpty(t, short)
2423
require.True(t, strings.HasPrefix(s, short), "%q %q", s, short)
@@ -29,14 +28,7 @@ func TestStringShort(t *testing.T) {
2928

3029
require.Equal(t, map[string][]string{
3130
"update": {
32-
"update(id_stable)",
33-
"update(id_changes)",
31+
"update_id",
3432
},
3533
}, shortMap)
3634
}
37-
38-
func TestNoStringer(t *testing.T) {
39-
// Users should explicitly choose between full and short name, no default String()
40-
_, hasStringer := any(ActionTypeNoop).(fmt.Stringer)
41-
require.False(t, hasStringer)
42-
}

bundle/direct/bundle_plan.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (b *DeploymentBundle) CalculatePlanForDeploy(ctx context.Context, client *d
130130
}
131131

132132
plan.Plan[resourceKey] = deployplan.PlanEntry{
133-
Action: actionType.StringFull(),
133+
Action: actionType.String(),
134134
}
135135

136136
return true
@@ -156,7 +156,7 @@ func (b *DeploymentBundle) CalculatePlanForDeploy(ctx context.Context, client *d
156156
continue
157157
}
158158
b.Graph.AddNode(n)
159-
plan.Plan[n] = deployplan.PlanEntry{Action: deployplan.ActionTypeDelete.StringFull()}
159+
plan.Plan[n] = deployplan.PlanEntry{Action: deployplan.ActionTypeDelete.String()}
160160
}
161161
}
162162

@@ -184,7 +184,7 @@ func (b *DeploymentBundle) CalculatePlanForDestroy(ctx context.Context, client *
184184
for key := range groupData {
185185
n := "resources." + group + "." + key
186186
b.Graph.AddNode(n)
187-
plan.Plan[n] = deployplan.PlanEntry{Action: deployplan.ActionTypeDelete.StringFull()}
187+
plan.Plan[n] = deployplan.PlanEntry{Action: deployplan.ActionTypeDelete.String()}
188188
}
189189
}
190190

0 commit comments

Comments
 (0)