mirror of
https://github.com/fluxcd/flagger.git
synced 2026-04-15 06:57:34 +00:00
validate if its an ARN
This commit is contained in:
@@ -57,7 +57,9 @@ type VirtualServiceReference struct {
|
||||
// +optional
|
||||
Namespace *string `json:"namespace,omitempty"`
|
||||
// Name is the name of VirtualService CR
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name,omitempty"`
|
||||
// ARN of the AWS VirtualService CR
|
||||
ARN string `json:"virtualServiceARN,omitempty"`
|
||||
}
|
||||
|
||||
// VirtualRouterReference holds a reference to VirtualRouter.appmesh.k8s.aws
|
||||
|
||||
@@ -104,12 +104,23 @@ func (ar *AppMeshv1beta2Router) reconcileVirtualNode(canary *flaggerv1.Canary, n
|
||||
|
||||
backends := make([]appmeshv1.Backend, 0)
|
||||
for _, b := range canary.Spec.Service.Backends {
|
||||
bk := appmeshv1.Backend{
|
||||
VirtualService: appmeshv1.VirtualServiceBackend{
|
||||
VirtualServiceRef: appmeshv1.VirtualServiceReference{
|
||||
Name: b,
|
||||
var bk appmeshv1.Backend
|
||||
if b[:6] == "arn:aws" {
|
||||
bk = appmeshv1.Backend{
|
||||
VirtualService: appmeshv1.VirtualServiceBackend{
|
||||
VirtualServiceRef: appmeshv1.VirtualServiceReference{
|
||||
ARN: b,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
} else {
|
||||
bk = appmeshv1.Backend{
|
||||
VirtualService: appmeshv1.VirtualServiceBackend{
|
||||
VirtualServiceRef: appmeshv1.VirtualServiceReference{
|
||||
Name: b,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
backends = append(backends, bk)
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func TestAppmeshv1beta2Router_Reconcile(t *testing.T) {
|
||||
|
||||
cdClone := cd.DeepCopy()
|
||||
backends := cdClone.Spec.Service.Backends
|
||||
backends = append(backends, "test.example.com")
|
||||
backends = append(backends, "test.example.com", "arn:aws:appmesh:eu-west-1:12345678910:mesh/my-mesh/virtualService/mytestservice")
|
||||
cdClone.Spec.Service.Backends = backends
|
||||
canary, err := mocks.flaggerClient.FlaggerV1beta1().Canaries("default").Update(context.TODO(), cdClone, metav1.UpdateOptions{})
|
||||
require.NoError(t, err)
|
||||
@@ -78,7 +78,7 @@ func TestAppmeshv1beta2Router_Reconcile(t *testing.T) {
|
||||
// verify
|
||||
vnPrimary, err = router.appmeshClient.AppmeshV1beta2().VirtualNodes("default").Get(context.TODO(), primaryName, metav1.GetOptions{})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, vnPrimary.Spec.Backends, 2)
|
||||
require.Len(t, vnPrimary.Spec.Backends, 3)
|
||||
|
||||
// update URI
|
||||
vrClone := vrApex.DeepCopy()
|
||||
|
||||
Reference in New Issue
Block a user