@@ -31,18 +31,15 @@ import (
31
31
policyv1 "k8s.io/api/policy/v1"
32
32
"k8s.io/apimachinery/pkg/api/equality"
33
33
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
34
- k8serrors "k8s.io/apimachinery/pkg/api/errors"
35
34
"k8s.io/apimachinery/pkg/api/resource"
36
35
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
37
- "k8s.io/apimachinery/pkg/labels"
38
36
k8slabels "k8s.io/apimachinery/pkg/labels"
39
37
"k8s.io/apimachinery/pkg/runtime/schema"
40
38
"k8s.io/apimachinery/pkg/types"
41
39
"k8s.io/apimachinery/pkg/util/intstr"
42
40
"sigs.k8s.io/controller-runtime/pkg/client"
43
41
44
42
"github.com/tsuru/rpaas-operator/api/v1alpha1"
45
- extensionsv1alpha1 "github.com/tsuru/rpaas-operator/api/v1alpha1"
46
43
controllerUtil "github.com/tsuru/rpaas-operator/internal/controllers/util"
47
44
"github.com/tsuru/rpaas-operator/internal/pkg/rpaas/nginx"
48
45
"github.com/tsuru/rpaas-operator/pkg/util"
@@ -145,16 +142,16 @@ main $@
145
142
`
146
143
)
147
144
148
- func (r * RpaasInstanceReconciler ) getRpaasInstance (ctx context.Context , objKey types.NamespacedName ) (* extensionsv1alpha1 .RpaasInstance , error ) {
149
- var instance extensionsv1alpha1 .RpaasInstance
145
+ func (r * RpaasInstanceReconciler ) getRpaasInstance (ctx context.Context , objKey types.NamespacedName ) (* v1alpha1 .RpaasInstance , error ) {
146
+ var instance v1alpha1 .RpaasInstance
150
147
if err := r .Client .Get (ctx , objKey , & instance ); err != nil {
151
148
return nil , err
152
149
}
153
150
154
151
return & instance , nil
155
152
}
156
153
157
- func (r * RpaasInstanceReconciler ) mergeWithFlavors (ctx context.Context , instance * v1alpha1.RpaasInstance ) (* extensionsv1alpha1 .RpaasInstance , error ) {
154
+ func (r * RpaasInstanceReconciler ) mergeWithFlavors (ctx context.Context , instance * v1alpha1.RpaasInstance ) (* v1alpha1 .RpaasInstance , error ) {
158
155
mergedInstance , err := r .mergeInstanceWithFlavors (ctx , instance )
159
156
if err != nil {
160
157
return nil , err
@@ -170,7 +167,7 @@ func (r *RpaasInstanceReconciler) mergeWithFlavors(ctx context.Context, instance
170
167
return mergedInstance , nil
171
168
}
172
169
173
- func (r * RpaasInstanceReconciler ) mergeInstanceWithFlavors (ctx context.Context , instance * extensionsv1alpha1 .RpaasInstance ) (* extensionsv1alpha1 .RpaasInstance , error ) {
170
+ func (r * RpaasInstanceReconciler ) mergeInstanceWithFlavors (ctx context.Context , instance * v1alpha1 .RpaasInstance ) (* v1alpha1 .RpaasInstance , error ) {
174
171
defaultFlavors , err := r .listDefaultFlavors (ctx , instance )
175
172
if err != nil {
176
173
return nil , err
@@ -186,7 +183,7 @@ func (r *RpaasInstanceReconciler) mergeInstanceWithFlavors(ctx context.Context,
186
183
flavorObjectKey .Namespace = instance .Spec .PlanNamespace
187
184
}
188
185
189
- var flavor extensionsv1alpha1 .RpaasFlavor
186
+ var flavor v1alpha1 .RpaasFlavor
190
187
if err := r .Client .Get (ctx , flavorObjectKey , & flavor ); err != nil {
191
188
return nil , err
192
189
}
@@ -209,7 +206,7 @@ func (r *RpaasInstanceReconciler) mergeInstanceWithFlavors(ctx context.Context,
209
206
return instance , nil
210
207
}
211
208
212
- func mergeInstanceWithFlavor (instance * extensionsv1alpha1 .RpaasInstance , flavor extensionsv1alpha1 .RpaasFlavor ) error {
209
+ func mergeInstanceWithFlavor (instance * v1alpha1 .RpaasInstance , flavor v1alpha1 .RpaasFlavor ) error {
213
210
if flavor .Spec .InstanceTemplate == nil {
214
211
return nil
215
212
}
@@ -222,7 +219,7 @@ func mergeInstanceWithFlavor(instance *extensionsv1alpha1.RpaasInstance, flavor
222
219
return nil
223
220
}
224
221
225
- func (r * RpaasInstanceReconciler ) listDefaultFlavors (ctx context.Context , instance * extensionsv1alpha1 .RpaasInstance ) ([]extensionsv1alpha1 .RpaasFlavor , error ) {
222
+ func (r * RpaasInstanceReconciler ) listDefaultFlavors (ctx context.Context , instance * v1alpha1 .RpaasInstance ) ([]v1alpha1 .RpaasFlavor , error ) {
226
223
flavorList := & v1alpha1.RpaasFlavorList {}
227
224
flavorNamespace := instance .Namespace
228
225
if instance .Spec .PlanNamespace != "" {
@@ -600,7 +597,7 @@ func (r *RpaasInstanceReconciler) reconcileHPA(ctx context.Context, instance *v1
600
597
func (r * RpaasInstanceReconciler ) cleanUpKEDAScaledObject (ctx context.Context , instance * v1alpha1.RpaasInstance ) error {
601
598
var so kedav1alpha1.ScaledObject
602
599
err := r .Client .Get (ctx , types.NamespacedName {Name : instance .Name , Namespace : instance .Namespace }, & so )
603
- if k8serrors .IsNotFound (err ) {
600
+ if k8sErrors .IsNotFound (err ) {
604
601
return nil
605
602
}
606
603
@@ -792,7 +789,7 @@ func (r *RpaasInstanceReconciler) reconcilePDB(ctx context.Context, instance *v1
792
789
var existingPDB policyv1.PodDisruptionBudget
793
790
err = r .Get (ctx , client.ObjectKey {Name : pdb .Name , Namespace : pdb .Namespace }, & existingPDB )
794
791
if err != nil {
795
- if ! k8serrors .IsNotFound (err ) {
792
+ if ! k8sErrors .IsNotFound (err ) {
796
793
return err
797
794
}
798
795
@@ -816,7 +813,7 @@ func (r *RpaasInstanceReconciler) reconcilePDB(ctx context.Context, instance *v1
816
813
}
817
814
818
815
func newPDB (instance * v1alpha1.RpaasInstance , nginx * nginxv1alpha1.Nginx ) (* policyv1.PodDisruptionBudget , error ) {
819
- set , err := labels .ConvertSelectorToLabelsMap (nginx .Status .PodSelector )
816
+ set , err := k8slabels .ConvertSelectorToLabelsMap (nginx .Status .PodSelector )
820
817
if err != nil {
821
818
return nil , err
822
819
}
@@ -884,6 +881,22 @@ func (r *RpaasInstanceReconciler) getNginx(ctx context.Context, instance *v1alph
884
881
return found , err
885
882
}
886
883
884
+ func (r * RpaasInstanceReconciler ) getNginxExternalAddressses (ctx context.Context , nginx * nginxv1alpha1.Nginx ) (v1alpha1.RpaasInstanceExternalAddressesStatus , error ) {
885
+ ingressesStatus := v1alpha1.RpaasInstanceExternalAddressesStatus {}
886
+
887
+ for _ , service := range nginx .Status .Services {
888
+ ingressesStatus .IPs = append (ingressesStatus .IPs , service .Hostnames ... )
889
+ ingressesStatus .Hostnames = append (ingressesStatus .Hostnames , service .Hostnames ... )
890
+ }
891
+
892
+ for _ , ingress := range nginx .Status .Ingresses {
893
+ ingressesStatus .IPs = append (ingressesStatus .IPs , ingress .Hostnames ... )
894
+ ingressesStatus .Hostnames = append (ingressesStatus .Hostnames , ingress .Hostnames ... )
895
+ }
896
+
897
+ return ingressesStatus , nil
898
+ }
899
+
887
900
func (r * RpaasInstanceReconciler ) reconcileNginx (ctx context.Context , instance * v1alpha1.RpaasInstance , nginx * nginxv1alpha1.Nginx ) error {
888
901
found , err := r .getNginx (ctx , instance )
889
902
if err != nil {
0 commit comments