-
Notifications
You must be signed in to change notification settings - Fork 46
/
iamauthpolicy.go
40 lines (35 loc) · 941 Bytes
/
iamauthpolicy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package lattice
import (
"fmt"
anv1alpha1 "github.com/aws/aws-application-networking-k8s/pkg/apis/applicationnetworking/v1alpha1"
"github.com/aws/aws-application-networking-k8s/pkg/utils"
)
type IAMAuthPolicy struct {
Type string
Name string
ResourceId string
Policy string
}
type IAMAuthPolicyStatus struct {
ResourceId string
}
func NewIAMAuthPolicy(k8sPolicy *anv1alpha1.IAMAuthPolicy) IAMAuthPolicy {
kind := k8sPolicy.Spec.TargetRef.Kind
policy := k8sPolicy.Spec.Policy
switch kind {
case "Gateway":
return IAMAuthPolicy{
Type: ServiceNetworkType,
Name: string(k8sPolicy.Spec.TargetRef.Name),
Policy: policy,
}
case "HTTPRoute", "GRPCRoute":
return IAMAuthPolicy{
Type: ServiceType,
Name: utils.LatticeServiceName(string(k8sPolicy.Spec.TargetRef.Name), k8sPolicy.Namespace),
Policy: policy,
}
default:
panic(fmt.Sprintf("unexpected targetRef, Kind=%s", kind))
}
}