Skip to content

Commit c70811c

Browse files
authored
feat(instance): add direction in security-group rule marshal (#3015)
1 parent cad6cae commit c70811c

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

internal/namespaces/instance/v1/custom_security_group.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ func marshalSecurityGroupRules(i interface{}, _ *human.MarshalOpt) (out string,
4545
rules := i.([]*instance.SecurityGroupRule)
4646

4747
type humanRule struct {
48-
ID string
49-
Protocol instance.SecurityGroupRuleProtocol
50-
Action instance.SecurityGroupRuleAction
51-
IPRange string
52-
Dest string
48+
ID string
49+
Direction string
50+
Protocol instance.SecurityGroupRuleProtocol
51+
Action instance.SecurityGroupRuleAction
52+
IPRange string
53+
Dest string
5354
}
5455

5556
toHumanRule := func(rule *instance.SecurityGroupRule) *humanRule {
@@ -61,11 +62,12 @@ func marshalSecurityGroupRules(i interface{}, _ *human.MarshalOpt) (out string,
6162
dest += "-" + strconv.Itoa(int(*rule.DestPortTo))
6263
}
6364
return &humanRule{
64-
ID: rule.ID,
65-
Protocol: rule.Protocol,
66-
Action: rule.Action,
67-
IPRange: rule.IPRange.String(),
68-
Dest: dest,
65+
ID: rule.ID,
66+
Direction: string(rule.Direction),
67+
Protocol: rule.Protocol,
68+
Action: rule.Action,
69+
IPRange: rule.IPRange.String(),
70+
Dest: dest,
6971
}
7072
}
7173
humanRules := make([]*humanRule, len(rules))

internal/namespaces/instance/v1/testdata/test-security-group-get-get.golden

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ ModificationDate few seconds ago
1515
Stateful true
1616

1717
Inbound Rules (default policy accept):
18-
ID PROTOCOL ACTION IP RANGE DEST
18+
ID DIRECTION PROTOCOL ACTION IP RANGE DEST
1919

2020
Outbound Rules (default policy accept):
21-
ID PROTOCOL ACTION IP RANGE DEST
22-
58909be7-d17c-4ac8-9eb3-23d5fc58abc5 TCP drop 0.0.0.0/0 25
23-
25680235-108b-4bbc-8e25-114303d950bd TCP drop 0.0.0.0/0 465
24-
4a31b633-118e-4900-bd52-facf1085fc8d TCP drop 0.0.0.0/0 587
25-
e7dd28e8-3747-4c7c-9a4f-35ae3f0ae2cd TCP drop ::/0 25
26-
f37d9e7c-8ed7-4e0f-baff-7f5e7ede0baf TCP drop ::/0 465
27-
68054851-54e3-46c9-9cd7-83219751248b TCP drop ::/0 587
21+
ID DIRECTION PROTOCOL ACTION IP RANGE DEST
22+
58909be7-d17c-4ac8-9eb3-23d5fc58abc5 outbound TCP drop 0.0.0.0/0 25
23+
25680235-108b-4bbc-8e25-114303d950bd outbound TCP drop 0.0.0.0/0 465
24+
4a31b633-118e-4900-bd52-facf1085fc8d outbound TCP drop 0.0.0.0/0 587
25+
e7dd28e8-3747-4c7c-9a4f-35ae3f0ae2cd outbound TCP drop ::/0 25
26+
f37d9e7c-8ed7-4e0f-baff-7f5e7ede0baf outbound TCP drop ::/0 465
27+
68054851-54e3-46c9-9cd7-83219751248b outbound TCP drop ::/0 587
2828

2929
Servers:
3030
ID NAME

0 commit comments

Comments
 (0)