func getEpinioURL(ctx context.Context, cluster *kubernetes.Cluster) (string, string, error) {
	ingresses, err := cluster.ListIngress(ctx, deployments.EpinioDeploymentID, "app.kubernetes.io/name=epinio")
	if err != nil {
		return "", "", errors.Wrap(err, "failed to list ingresses for epinio api server")
	}
	if len(ingresses.Items) < 1 {
		return "", "", errors.New("epinio api ingress not found")
	}
	if len(ingresses.Items) > 1 {
		return "", "", errors.New("more than one epinio api ingress found")
	}
	if len(ingresses.Items[0].Spec.Rules) < 1 {
		return "", "", errors.New("epinio api ingress has no rules")
	}
	if len(ingresses.Items[0].Spec.Rules) > 1 {
		return "", "", errors.New("epinio api ingress has more than on rule")
	}
	host := ingresses.Items[0].Spec.Rules[0].Host
	return fmt.Sprintf("%s://%s", epinioAPIProtocol, host), fmt.Sprintf("%s://%s", epinioWSProtocol, host), nil
}
getEpinioURL finds the URL's for epinio from the cluster
package admincmd
import (
	"context"
	"fmt"
	"github.com/epinio/epinio/deployments"
	"github.com/epinio/epinio/helpers/kubernetes"
	"github.com/epinio/epinio/helpers/termui"
	"github.com/epinio/epinio/helpers/tracelog"
	"github.com/epinio/epinio/internal/auth"
	"github.com/epinio/epinio/internal/cli/config"
	"github.com/epinio/epinio/internal/duration"
	"github.com/go-logr/logr"
	"github.com/pkg/errors"
)
const (
	epinioAPIProtocol = "https"
	epinioWSProtocol  = "wss"
)
type Admin struct {
	Config *config.Config
	Log    logr.Logger
	ui     *termui.UI
}
func New() (*Admin, error) {
	configConfig, err := config.Load()
	if err != nil {
		return nil, err
	}
	uiUI := termui.NewUI()
	logger := tracelog.NewLogger().WithName("EpinioConfig").V(3)
	return &Admin{
		ui:     uiUI,
		Config: configConfig,
		Log:    logger,
	}, nil
}
func (a *Admin) ConfigUpdate(ctx context.Context) error {
	log := a.Log.WithName("ConfigUpdate")
	log.Info("start")
	defer log.Info("return")
	details := log.V(1)  
	a.ui.Note().
		WithStringValue("Config", a.Config.Location).
		Msg("Updating the stored credentials from the current cluster")
	details.Info("retrieving credentials")
	user, password, err := auth.GetFirstUserAccount(ctx)
	if err != nil {
		a.ui.Exclamation().Msg(err.Error())
		return nil
	}
	details.Info("retrieved credentials", "user", user, "password", password)
	details.Info("retrieving server locations")
	api, wss, err := getAPI(ctx, details)
	if err != nil {
		a.ui.Exclamation().Msg(err.Error())
		return nil
	}
	details.Info("retrieved server locations", "api", api, "wss", wss)
	details.Info("retrieving certs")
	certs, err := getCerts(ctx, details)
	if err != nil {
		a.ui.Exclamation().Msg(err.Error())
		return nil
	}
	details.Info("retrieved certs", "certs", certs)
	a.Config.User = user
	a.Config.Password = password
	a.Config.API = api
	a.Config.WSS = wss
	a.Config.Certs = certs
	details.Info("saving",
		"user", a.Config.User,
		"pass", a.Config.Password,
		"api", a.Config.API,
		"wss", a.Config.WSS,
		"cert", a.Config.Certs)
	err = a.Config.Save()
	if err != nil {
		a.ui.Exclamation().Msg(errors.Wrap(err, "failed to save configuration").Error())
		return nil
	}
	details.Info("saved")
	a.ui.Success().Msg("Ok")
	return nil
}
func getAPI(ctx context.Context, log logr.Logger) (string, string, error) {
	cluster, err := kubernetes.GetCluster(ctx)
	if err != nil {
		return "", "", err
	}
	log.Info("got cluster")
	epinioURL, epinioWsURL, err := getEpinioURL(ctx, cluster)
	if err != nil {
		return "", "", errors.Wrap(err, "failed to resolve epinio api host")
	}
	return epinioURL, epinioWsURL, err
}
func getCerts(ctx context.Context, log logr.Logger) (string, error) {
	cluster, err := kubernetes.GetCluster(ctx)
	if err != nil {
		return "", err
	}
	log.Info("got cluster")
	secret, err := cluster.WaitForSecret(ctx,
		deployments.EpinioDeploymentID,
		deployments.EpinioDeploymentID+"-tls",
		duration.ToServiceSecret(),
	)
	if err != nil {
		return "", errors.Wrap(err, "failed to get API CA cert secret")
	}
	log.Info("got secret", "secret", deployments.EpinioDeploymentID+"-tls")
	return string(secret.Data["ca.crt"]), nil
}