Skip to content

Commit 159e412

Browse files
committed
format imports
Signed-off-by: Lukas Hoehl <[email protected]>
1 parent 76723f9 commit 159e412

File tree

1 file changed

+52
-52
lines changed

1 file changed

+52
-52
lines changed

pkg/envoyfilters/envoyfilters.go

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import (
77
"strings"
88

99
envoy_corev3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
10-
envoyconfig_rbacv3 "github.com/envoyproxy/go-control-plane/envoy/config/rbac/v3"
10+
envoy_rbacv3 "github.com/envoyproxy/go-control-plane/envoy/config/rbac/v3"
1111
envoy_routev3 "github.com/envoyproxy/go-control-plane/envoy/config/route/v3"
12-
envoyhttp_rbacv3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/rbac/v3"
13-
envoynetwork_rbacv3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/rbac/v3"
14-
matcherv3 "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3"
12+
envoy_httprbacv3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/rbac/v3"
13+
envoy_networkrbacv3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/rbac/v3"
14+
envoy_matcherv3 "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3"
1515
"github.com/gardener/gardener/extensions/pkg/controller"
1616
"google.golang.org/protobuf/encoding/protojson"
1717
"google.golang.org/protobuf/proto"
@@ -38,12 +38,12 @@ type ACLRule struct {
3838
Type string `json:"type"`
3939
}
4040

41-
func (r *ACLRule) actionProto() envoyconfig_rbacv3.RBAC_Action {
41+
func (r *ACLRule) actionProto() envoy_rbacv3.RBAC_Action {
4242
switch r.Action {
4343
case "DENY":
44-
return envoyconfig_rbacv3.RBAC_DENY
44+
return envoy_rbacv3.RBAC_DENY
4545
case "ALLOW":
46-
return envoyconfig_rbacv3.RBAC_ALLOW
46+
return envoy_rbacv3.RBAC_ALLOW
4747
default:
4848
panic("unknown action")
4949
}
@@ -164,19 +164,19 @@ func ingressConfigPatchFromRule(
164164
rbacName := "acl-ingress"
165165
ingressSuffix := "-" + shootID + "." + seedIngressDomain
166166

167-
rbacFilter := &envoynetwork_rbacv3.RBAC{
167+
rbacFilter := &envoy_networkrbacv3.RBAC{
168168
StatPrefix: "envoyrbac",
169-
Rules: &envoyconfig_rbacv3.RBAC{
170-
Action: envoyconfig_rbacv3.RBAC_ALLOW,
171-
Policies: map[string]*envoyconfig_rbacv3.Policy{
169+
Rules: &envoy_rbacv3.RBAC{
170+
Action: envoy_rbacv3.RBAC_ALLOW,
171+
Policies: map[string]*envoy_rbacv3.Policy{
172172
shootID + "-inverse": {
173-
Permissions: []*envoyconfig_rbacv3.Permission{
173+
Permissions: []*envoy_rbacv3.Permission{
174174
{
175-
Rule: &envoyconfig_rbacv3.Permission_NotRule{
176-
NotRule: &envoyconfig_rbacv3.Permission{
177-
Rule: &envoyconfig_rbacv3.Permission_RequestedServerName{
178-
RequestedServerName: &matcherv3.StringMatcher{
179-
MatchPattern: &matcherv3.StringMatcher_Suffix{
175+
Rule: &envoy_rbacv3.Permission_NotRule{
176+
NotRule: &envoy_rbacv3.Permission{
177+
Rule: &envoy_rbacv3.Permission_RequestedServerName{
178+
RequestedServerName: &envoy_matcherv3.StringMatcher{
179+
MatchPattern: &envoy_matcherv3.StringMatcher_Suffix{
180180
Suffix: ingressSuffix,
181181
},
182182
},
@@ -185,9 +185,9 @@ func ingressConfigPatchFromRule(
185185
},
186186
},
187187
},
188-
Principals: []*envoyconfig_rbacv3.Principal{
188+
Principals: []*envoy_rbacv3.Principal{
189189
{
190-
Identifier: &envoyconfig_rbacv3.Principal_RemoteIp{
190+
Identifier: &envoy_rbacv3.Principal_RemoteIp{
191191
RemoteIp: &envoy_corev3.CidrRange{
192192
AddressPrefix: "0.0.0.0",
193193
PrefixLen: wrapperspb.UInt32(0),
@@ -197,11 +197,11 @@ func ingressConfigPatchFromRule(
197197
},
198198
},
199199
shootID: {
200-
Permissions: []*envoyconfig_rbacv3.Permission{
200+
Permissions: []*envoy_rbacv3.Permission{
201201
{
202-
Rule: &envoyconfig_rbacv3.Permission_RequestedServerName{
203-
RequestedServerName: &matcherv3.StringMatcher{
204-
MatchPattern: &matcherv3.StringMatcher_Suffix{
202+
Rule: &envoy_rbacv3.Permission_RequestedServerName{
203+
RequestedServerName: &envoy_matcherv3.StringMatcher{
204+
MatchPattern: &envoy_matcherv3.StringMatcher_Suffix{
205205
Suffix: ingressSuffix,
206206
},
207207
},
@@ -250,8 +250,8 @@ func vpnConfigPatchFromRule(rule *ACLRule,
250250
headerMatcher := envoy_routev3.HeaderMatcher{
251251
Name: "reversed-vpn",
252252
HeaderMatchSpecifier: &envoy_routev3.HeaderMatcher_StringMatch{
253-
StringMatch: &matcherv3.StringMatcher{
254-
MatchPattern: &matcherv3.StringMatcher_Contains{
253+
StringMatch: &envoy_matcherv3.StringMatcher{
254+
MatchPattern: &envoy_matcherv3.StringMatcher_Contains{
255255
// The actual header value will look something like
256256
// `outbound|1194||vpn-seed-server.<technical-ID>.svc.cluster.local`.
257257
// Include dots in the contains matcher as anchors, to always match the entire technical shoot ID.
@@ -265,26 +265,26 @@ func vpnConfigPatchFromRule(rule *ACLRule,
265265
},
266266
}
267267

268-
rbacFilter := &envoyhttp_rbacv3.RBAC{
268+
rbacFilter := &envoy_httprbacv3.RBAC{
269269
RulesStatPrefix: "envoyrbac",
270-
Rules: &envoyconfig_rbacv3.RBAC{
271-
Action: envoyconfig_rbacv3.RBAC_ALLOW,
272-
Policies: map[string]*envoyconfig_rbacv3.Policy{
270+
Rules: &envoy_rbacv3.RBAC{
271+
Action: envoy_rbacv3.RBAC_ALLOW,
272+
Policies: map[string]*envoy_rbacv3.Policy{
273273
shortShootID + "-inverse": {
274-
Permissions: []*envoyconfig_rbacv3.Permission{
274+
Permissions: []*envoy_rbacv3.Permission{
275275
{
276-
Rule: &envoyconfig_rbacv3.Permission_NotRule{
277-
NotRule: &envoyconfig_rbacv3.Permission{
278-
Rule: &envoyconfig_rbacv3.Permission_Header{
276+
Rule: &envoy_rbacv3.Permission_NotRule{
277+
NotRule: &envoy_rbacv3.Permission{
278+
Rule: &envoy_rbacv3.Permission_Header{
279279
Header: &headerMatcher,
280280
},
281281
},
282282
},
283283
},
284284
},
285-
Principals: []*envoyconfig_rbacv3.Principal{
285+
Principals: []*envoy_rbacv3.Principal{
286286
{
287-
Identifier: &envoyconfig_rbacv3.Principal_RemoteIp{
287+
Identifier: &envoy_rbacv3.Principal_RemoteIp{
288288
RemoteIp: &envoy_corev3.CidrRange{
289289
AddressPrefix: "0.0.0.0",
290290
PrefixLen: wrapperspb.UInt32(0),
@@ -294,9 +294,9 @@ func vpnConfigPatchFromRule(rule *ACLRule,
294294
},
295295
},
296296
shortShootID: {
297-
Permissions: []*envoyconfig_rbacv3.Permission{
297+
Permissions: []*envoy_rbacv3.Permission{
298298
{
299-
Rule: &envoyconfig_rbacv3.Permission_Header{
299+
Rule: &envoy_rbacv3.Permission_Header{
300300
Header: &headerMatcher,
301301
},
302302
},
@@ -358,8 +358,8 @@ func CreateInternalFilterPatchFromRule(
358358
// into a list of envoy principals. The function checks for the rule action: If
359359
// the action is "ALLOW", the alwaysAllowedCIDRs are appended to the principals
360360
// to guarantee the downstream flow for these CIDRs is not blocked.
361-
func ruleCIDRsToPrincipal(rule *ACLRule, alwaysAllowedCIDRs []string) []*envoyconfig_rbacv3.Principal {
362-
principals := []*envoyconfig_rbacv3.Principal{}
361+
func ruleCIDRsToPrincipal(rule *ACLRule, alwaysAllowedCIDRs []string) []*envoy_rbacv3.Principal {
362+
principals := []*envoy_rbacv3.Principal{}
363363

364364
for _, cidr := range rule.Cidrs {
365365
prefix, length, err := getPrefixAndPrefixLength(cidr)
@@ -370,14 +370,14 @@ func ruleCIDRsToPrincipal(rule *ACLRule, alwaysAllowedCIDRs []string) []*envoyco
370370
AddressPrefix: prefix,
371371
PrefixLen: wrapperspb.UInt32(uint32(length)),
372372
}
373-
p := new(envoyconfig_rbacv3.Principal)
373+
p := new(envoy_rbacv3.Principal)
374374
switch strings.ToLower(rule.Type) {
375375
case "source_ip":
376-
p.Identifier = &envoyconfig_rbacv3.Principal_SourceIp{SourceIp: &cidrRange}
376+
p.Identifier = &envoy_rbacv3.Principal_SourceIp{SourceIp: &cidrRange}
377377
case "remote_ip":
378-
p.Identifier = &envoyconfig_rbacv3.Principal_RemoteIp{RemoteIp: &cidrRange}
378+
p.Identifier = &envoy_rbacv3.Principal_RemoteIp{RemoteIp: &cidrRange}
379379
case "direct_remote_ip":
380-
p.Identifier = &envoyconfig_rbacv3.Principal_DirectRemoteIp{DirectRemoteIp: &cidrRange}
380+
p.Identifier = &envoy_rbacv3.Principal_DirectRemoteIp{DirectRemoteIp: &cidrRange}
381381
default:
382382
continue
383383
}
@@ -393,8 +393,8 @@ func ruleCIDRsToPrincipal(rule *ACLRule, alwaysAllowedCIDRs []string) []*envoyco
393393
if err != nil {
394394
continue
395395
}
396-
principals = append(principals, &envoyconfig_rbacv3.Principal{
397-
Identifier: &envoyconfig_rbacv3.Principal_RemoteIp{
396+
principals = append(principals, &envoy_rbacv3.Principal{
397+
Identifier: &envoy_rbacv3.Principal_RemoteIp{
398398
RemoteIp: &envoy_corev3.CidrRange{
399399
AddressPrefix: prefix,
400400
PrefixLen: wrapperspb.UInt32(uint32(length)),
@@ -420,7 +420,7 @@ func getPrefixAndPrefixLength(cidr string) (prefix string, prefixLen int, err er
420420
}
421421

422422
func principalsToPatch(
423-
rbacName string, ruleAction envoyconfig_rbacv3.RBAC_Action, principals []*envoyconfig_rbacv3.Principal,
423+
rbacName string, ruleAction envoy_rbacv3.RBAC_Action, principals []*envoy_rbacv3.Principal,
424424
) *istio_networkingv1alpha3.EnvoyFilter_Patch {
425425
rbacFilter := newRBACFilter(rbacName, ruleAction, principals)
426426
typedConfig, err := protoMessageToTypedConfig(rbacFilter)
@@ -438,16 +438,16 @@ func principalsToPatch(
438438
}
439439
}
440440

441-
func newRBACFilter(rbacName string, ruleAction envoyconfig_rbacv3.RBAC_Action, principals []*envoyconfig_rbacv3.Principal) *envoynetwork_rbacv3.RBAC {
442-
return &envoynetwork_rbacv3.RBAC{
441+
func newRBACFilter(rbacName string, ruleAction envoy_rbacv3.RBAC_Action, principals []*envoy_rbacv3.Principal) *envoy_networkrbacv3.RBAC {
442+
return &envoy_networkrbacv3.RBAC{
443443
StatPrefix: "envoyrbac",
444-
Rules: &envoyconfig_rbacv3.RBAC{
444+
Rules: &envoy_rbacv3.RBAC{
445445
Action: ruleAction,
446-
Policies: map[string]*envoyconfig_rbacv3.Policy{
446+
Policies: map[string]*envoy_rbacv3.Policy{
447447
rbacName: {
448-
Permissions: []*envoyconfig_rbacv3.Permission{
448+
Permissions: []*envoy_rbacv3.Permission{
449449
{
450-
Rule: &envoyconfig_rbacv3.Permission_Any{
450+
Rule: &envoy_rbacv3.Permission_Any{
451451
Any: true,
452452
},
453453
},

0 commit comments

Comments
 (0)