Skip to content

Commit

Permalink
Merge pull request #1034 from jonnylangefeld/jlf/add-metadata-to-isti…
Browse files Browse the repository at this point in the history
…o-vs

Add metadata annotations to generated apex objects
  • Loading branch information
stefanprodan authored Oct 27, 2021
2 parents 3658482 + d5994ac commit d832937
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 10 deletions.
17 changes: 15 additions & 2 deletions pkg/router/appmesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,23 @@ func (ar *AppMeshRouter) reconcileVirtualNode(canary *flaggerv1.Canary, name str

// create virtual node
if errors.IsNotFound(err) {
metadata := canary.Spec.Service.Apex
if metadata == nil {
metadata = &flaggerv1.CustomMetadata{}
}
if metadata.Labels == nil {
metadata.Labels = make(map[string]string)
}
if metadata.Annotations == nil {
metadata.Annotations = make(map[string]string)
}

virtualnode = &appmeshv1.VirtualNode{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: canary.Namespace,
Name: name,
Namespace: canary.Namespace,
Labels: metadata.Labels,
Annotations: filterMetadata(metadata.Annotations),
OwnerReferences: []metav1.OwnerReference{
*metav1.NewControllerRef(canary, schema.GroupVersionKind{
Group: flaggerv1.SchemeGroupVersion.Group,
Expand Down
17 changes: 15 additions & 2 deletions pkg/router/appmesh_v1beta2.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,23 @@ func (ar *AppMeshv1beta2Router) reconcileVirtualNode(canary *flaggerv1.Canary, n

// create virtual node
if errors.IsNotFound(err) {
metadata := canary.Spec.Service.Apex
if metadata == nil {
metadata = &flaggerv1.CustomMetadata{}
}
if metadata.Labels == nil {
metadata.Labels = make(map[string]string)
}
if metadata.Annotations == nil {
metadata.Annotations = make(map[string]string)
}

virtualnode = &appmeshv1.VirtualNode{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: canary.Namespace,
Name: name,
Namespace: canary.Namespace,
Labels: metadata.Labels,
Annotations: filterMetadata(metadata.Annotations),
OwnerReferences: []metav1.OwnerReference{
*metav1.NewControllerRef(canary, schema.GroupVersionKind{
Group: flaggerv1.SchemeGroupVersion.Group,
Expand Down
17 changes: 15 additions & 2 deletions pkg/router/contour.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,23 @@ func (cr *ContourRouter) Reconcile(canary *flaggerv1.Canary) error {

proxy, err := cr.contourClient.ProjectcontourV1().HTTPProxies(canary.Namespace).Get(context.TODO(), apexName, metav1.GetOptions{})
if errors.IsNotFound(err) {
metadata := canary.Spec.Service.Apex
if metadata == nil {
metadata = &flaggerv1.CustomMetadata{}
}
if metadata.Labels == nil {
metadata.Labels = make(map[string]string)
}
if metadata.Annotations == nil {
metadata.Annotations = make(map[string]string)
}

proxy = &contourv1.HTTPProxy{
ObjectMeta: metav1.ObjectMeta{
Name: apexName,
Namespace: canary.Namespace,
Name: apexName,
Namespace: canary.Namespace,
Labels: metadata.Labels,
Annotations: filterMetadata(metadata.Annotations),
OwnerReferences: []metav1.OwnerReference{
*metav1.NewControllerRef(canary, schema.GroupVersionKind{
Group: flaggerv1.SchemeGroupVersion.Group,
Expand Down
17 changes: 15 additions & 2 deletions pkg/router/gloo.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,23 @@ func (gr *GlooRouter) Reconcile(canary *flaggerv1.Canary) error {

routeTable, err := gr.glooClient.GatewayV1().RouteTables(canary.Namespace).Get(context.TODO(), apexName, metav1.GetOptions{})
if errors.IsNotFound(err) {
metadata := canary.Spec.Service.Apex
if metadata == nil {
metadata = &flaggerv1.CustomMetadata{}
}
if metadata.Labels == nil {
metadata.Labels = make(map[string]string)
}
if metadata.Annotations == nil {
metadata.Annotations = make(map[string]string)
}

routeTable = &gatewayv1.RouteTable{
ObjectMeta: metav1.ObjectMeta{
Name: apexName,
Namespace: canary.Namespace,
Name: apexName,
Namespace: canary.Namespace,
Labels: metadata.Labels,
Annotations: filterMetadata(metadata.Annotations),
OwnerReferences: []metav1.OwnerReference{
*metav1.NewControllerRef(canary, schema.GroupVersionKind{
Group: flaggerv1.SchemeGroupVersion.Group,
Expand Down
17 changes: 15 additions & 2 deletions pkg/router/istio.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,23 @@ func (ir *IstioRouter) reconcileVirtualService(canary *flaggerv1.Canary) error {
virtualService, err := ir.istioClient.NetworkingV1alpha3().VirtualServices(canary.Namespace).Get(context.TODO(), apexName, metav1.GetOptions{})
// insert
if errors.IsNotFound(err) {
metadata := canary.Spec.Service.Apex
if metadata == nil {
metadata = &flaggerv1.CustomMetadata{}
}
if metadata.Labels == nil {
metadata.Labels = make(map[string]string)
}
if metadata.Annotations == nil {
metadata.Annotations = make(map[string]string)
}

virtualService = &istiov1alpha3.VirtualService{
ObjectMeta: metav1.ObjectMeta{
Name: apexName,
Namespace: canary.Namespace,
Name: apexName,
Namespace: canary.Namespace,
Labels: metadata.Labels,
Annotations: filterMetadata(metadata.Annotations),
OwnerReferences: []metav1.OwnerReference{
*metav1.NewControllerRef(canary, schema.GroupVersionKind{
Group: flaggerv1.SchemeGroupVersion.Group,
Expand Down

0 comments on commit d832937

Please sign in to comment.