// GetDefaultAppName returns randomly generated application name with unique configurable prefix suffixed by a randomly generated string which can be used as a default name in case the user doesn't provide a name.
GetDefaultAppName returns randomly generated application name with unique configurable prefix suffixed by a randomly generated string which can be used as a default name in case the user doesn't provide a name.
// GetDefaultAppName returns randomly generated application name with unique configurable prefix suffixed by a randomly generated string which can be used as a default name in case the user doesn ' t provide a name .
func GetDefaultAppName(existingApps []config.ApplicationInfo) (string, error) {
	var appName string
	var existingAppNames []string
	for _, app := range existingApps {
		existingAppNames = append(existingAppNames, app.Name)
	}
	cfg, err := config.New()
	if err != nil {
		return "", errors.Wrap(err, "unable to fetch config")
	}
	if cfg.OdoSettings.NamePrefix == nil || *cfg.OdoSettings.NamePrefix == "" {
		prefix, err := component.GetComponentDir("", occlient.NONE)
		if err != nil {
			return "", errors.Wrap(err, "unable to generate random app name")
		}
		appName, err = util.GetRandomName(prefix, appPrefixMaxLen, existingAppNames, appNameMaxRetries)
		if err != nil {
			return "", errors.Wrap(err, "unable to generate random app name")
		}
	} else {
		appName, err = util.GetRandomName(*cfg.OdoSettings.NamePrefix, appPrefixMaxLen, existingAppNames, appNameMaxRetries)
	}
	if err != nil {
		return "", errors.Wrap(err, "unable to generate random app name")
	}
	return util.GetDNS1123Name(appName), nil
}
func GetDefaultAppName ( existingApps [ ] config . ApplicationInfo ) ( string , error ) { var appName string var existingAppNames [ ] string for _ , app := range existingApps { existingAppNames = append ( existingAppNames , app . Name ) } cfg , err := config . New ( ) if err != nil { return " " , errors . Wrap ( err , " " ) } if cfg . OdoSettings . NamePrefix == nil || * cfg . OdoSettings . NamePrefix == " " { prefix , err := component . GetComponentDir ( " " , occlient . NONE ) if err != nil { return " " , errors . Wrap ( err , " " ) } appName , err = util . GetRandomName ( prefix , appPrefixMaxLen , existingAppNames , appNameMaxRetries ) if err != nil { return " " , errors . Wrap ( err , " " ) } } else { appName , err = util . GetRandomName ( * cfg . OdoSettings . NamePrefix , appPrefixMaxLen , existingAppNames , appNameMaxRetries ) } if err != nil { return " " , errors . Wrap ( err , " " ) } return util . GetDNS1123Name ( appName ) , nil }
GetDefaultAppName returns randomly generated application name with unique configurable prefix suffixed by a randomly generated string which can be used as a default name in case the user doesn't provide a name.
GetDefaultAppName returns randomly generated application name with unique configurable prefix suffixed by a randomly generated string which can be used as a default name in case the user doesn ' t provide a name .
// Get list of app names // Get the desired app name prefix from odo config // If there's no prefix in config file or it is equal to $DIR, use safe default which is the name of current directory