github.com/verrazzano/verrazzano@v1.7.0/pkg/k8s/ready/ingresses_present.go (about) 1 // Copyright (c) 2021, 2022, Oracle and/or its affiliates. 2 // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 package ready 4 5 import ( 6 "context" 7 8 "github.com/verrazzano/verrazzano/pkg/log/vzlog" 9 10 v1 "k8s.io/api/networking/v1" 11 "k8s.io/apimachinery/pkg/api/errors" 12 "k8s.io/apimachinery/pkg/types" 13 clipkg "sigs.k8s.io/controller-runtime/pkg/client" 14 ) 15 16 // IngressesPresent Check that the named ingresses are present in the cluster 17 func IngressesPresent(log vzlog.VerrazzanoLogger, client clipkg.Client, ingressNames []types.NamespacedName, prefix string) bool { 18 for _, ingName := range ingressNames { 19 ing := v1.Ingress{} 20 if err := client.Get(context.TODO(), ingName, &ing); err != nil { 21 if errors.IsNotFound(err) { 22 log.Progressf("%s is waiting for ingress %v to exist", prefix, ingressNames) 23 // Ingress not found 24 return false 25 } 26 log.Errorf("Failed getting ingress %v: %v", ingressNames, err) 27 return false 28 } 29 } 30 log.Oncef("%s has all the required ingresses %v", prefix, ingressNames) 31 return true 32 }