Skip to content

Instantly share code, notes, and snippets.

@TsuyoshiUshio
Created January 20, 2020 07:56
Show Gist options
  • Save TsuyoshiUshio/7ca1278a7515be1f10370a04c461b51d to your computer and use it in GitHub Desktop.
Save TsuyoshiUshio/7ca1278a7515be1f10370a04c461b51d to your computer and use it in GitHub Desktop.
Helper method for IPAddress creation for service.
func WaitUntilServiceExternalIPsAvailable(t *testing.T, options *k8s.KubectlOptions, serviceName string, retries int, sleepBetweenRetries time.Duration) {
statusMsg := fmt.Sprintf("Wait for service %s to be provisioned.", serviceName)
message := retry.DoWithRetry(
t,
statusMsg,
retries,
sleepBetweenRetries,
func() (string, error) {
service, err := k8s.GetServiceE(t, options, serviceName)
if err != nil {
return "", err
}
if len(service.Status.LoadBalancer.Ingress) == 0 {
return "", k8s.NewServiceNotAvailableError(service)
}
return "Service ExternalIP is now available", nil
},
)
logger.Logf(t, message)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment