// GetCurrentOrGetCreateSetDefault returns currently active application.
// If no application is active, a defaultApplication is created and set as
// default as well.
// Use this carefully only in places where user expects the state to be altered
// Do not use for read operations like get, list; only for write operations like
// create
GetCurrentOrGetCreateSetDefault returns currently active application.
If no application is active, a defaultApplication is created and set as
default as well.
Use this carefully only in places where user expects the state to be altered
Do not use for read operations like get, list; only for write operations like
create
// GetCurrentOrGetCreateSetDefault returns currently active application . // If no application is active a defaultApplication is created and set as // default as well . // Use this carefully only in places where user expects the state to be altered // Do not use for read operations like get list ; only for write operations like // create
func GetCurrentOrGetCreateSetDefault(client *occlient.Client) (string, error) {
	currentApp, err := GetCurrent(client.Namespace)
	if err != nil {
		return "", errors.Wrap(err, "unable to get active application")
	}
	if currentApp == "" {
		defaultName, err := GetDefaultAppName([]config.ApplicationInfo{})
		if err != nil {
			return "", errors.Wrap(err, "unable to fetch/create an application to set as active")
		}
		currentApp = defaultName
		exists, _ := Exists(client, currentApp)
		if !exists {
			if err := Create(client, currentApp); err != nil {
				return "", errors.Wrapf(err, "unable to create app %v", currentApp)
			}
		}
		if err := SetCurrent(client, currentApp); err != nil {
			return "", errors.Wrapf(err, "unable to set %v as the current application", currentApp)
		}
	}
	return currentApp, nil
}
func GetCurrentOrGetCreateSetDefault ( client * occlient . Client ) ( string , error ) { currentApp , err := GetCurrent ( client . Namespace ) if err != nil { return " " , errors . Wrap ( err , " " ) } if currentApp == " " { defaultName , err := GetDefaultAppName ( [ ] config . ApplicationInfo { } ) if err != nil { return " " , errors . Wrap ( err , " " ) } currentApp = defaultName exists , _ := Exists ( client , currentApp ) if ! exists { if err := Create ( client , currentApp ) ; err != nil { return " " , errors . Wrapf ( err , " " , currentApp ) } } if err := SetCurrent ( client , currentApp ) ; err != nil { return " " , errors . Wrapf ( err , " " , currentApp ) } } return currentApp , nil }
GetCurrentOrGetCreateSetDefault returns currently active application.
GetCurrentOrGetCreateSetDefault returns currently active application .
// if no Application is active use default // get default application name // create if default application does not exist // set default application as the current application