Skip to content

Commit b39eff8

Browse files
committed
Fix vcl condition --comment flag
The --comment flag was setting the statement instead of the comment, and was missing from the no-arguments validation check.
1 parent 97b3f59 commit b39eff8

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
### Bug Fixes:
88

9+
- fix(vcl/condition): `--comment` flag in `condition update` now correctly sets the comment instead of overwriting the statement
10+
911
### Enhancements:
1012

1113
### Dependencies:

pkg/commands/service/vcl/condition/condition_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func TestConditionUpdate(t *testing.T) {
8686
CloneVersionFn: testutil.CloneVersionResult(4),
8787
UpdateConditionFn: updateConditionOK,
8888
},
89-
WantError: "error parsing arguments: must provide either --new-name, --statement, --type or --priority to update condition",
89+
WantError: "error parsing arguments: must provide either --new-name, --statement, --type, --priority or --comment to update condition",
9090
},
9191
{
9292
Args: "--service-id 123 --version 1 --name always_false --new-name false_always --autoclone",

pkg/commands/service/vcl/condition/update.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error {
9797
c.input.ServiceVersion = fastly.ToValue(serviceVersion.Number)
9898

9999
// If no argument are provided, error with useful message.
100-
if !c.newName.WasSet && !c.priority.WasSet && !c.statement.WasSet && !c.conditionType.WasSet {
101-
return fmt.Errorf("error parsing arguments: must provide either --new-name, --statement, --type or --priority to update condition")
100+
if !c.newName.WasSet && !c.priority.WasSet && !c.statement.WasSet && !c.conditionType.WasSet && !c.comment.WasSet {
101+
return fmt.Errorf("error parsing arguments: must provide either --new-name, --statement, --type, --priority or --comment to update condition")
102102
}
103103

104104
if c.newName.WasSet {
@@ -114,7 +114,7 @@ func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error {
114114
c.input.Statement = &c.statement.Value
115115
}
116116
if c.comment.WasSet {
117-
c.input.Statement = &c.comment.Value
117+
c.input.Comment = &c.comment.Value
118118
}
119119

120120
r, err := c.Globals.APIClient.UpdateCondition(context.TODO(), &c.input)

0 commit comments

Comments
 (0)