// SetCurrent set application as active
SetCurrent set application as active
// SetCurrent set application as active
func SetCurrent(client *occlient.Client, appName string) error {
	err := project.SetCurrent(client, client.Namespace)
	if err != nil {
		return errors.Wrap(err, "unable to set current project")
	}
	glog.V(4).Infof("Setting application %s as current.\n", appName)
	cfg, err := config.New()
	if err != nil {
		return errors.Wrap(err, "unable to set current application")
	}
	exists, err := Exists(client, appName)
	if err != nil {
		return errors.Wrap(err, "unable to set current application")
	}
	if !exists {
		return fmt.Errorf("application %s doesn't exist", appName)
	}
	found := false
	for _, cfgApp := range cfg.ActiveApplications {
		if cfgApp.Project == client.Namespace && cfgApp.Name == appName {
			found = true
			break
		}
	}
	if !found {
		err := cfg.AddApplication(appName, client.Namespace)
		if err != nil {
			return errors.Wrap(err, "unable to add application")
		}
	}
	err = cfg.SetActiveApplication(appName, client.Namespace)
	if err != nil {
		return errors.Wrap(err, "unable to set current application")
	}
	return nil
}
func SetCurrent ( client * occlient . Client , appName string ) error { err := project . SetCurrent ( client , client . Namespace ) if err != nil { return errors . Wrap ( err , " " ) } glog . V ( 4 ) . Infof ( " \n " , appName ) cfg , err := config . New ( ) if err != nil { return errors . Wrap ( err , " " ) } exists , err := Exists ( client , appName ) if err != nil { return errors . Wrap ( err , " " ) } if ! exists { return fmt . Errorf ( " " , appName ) } found := false for _ , cfgApp := range cfg . ActiveApplications { if cfgApp . Project == client . Namespace && cfgApp . Name == appName { found = true break } } if ! found { err := cfg . AddApplication ( appName , client . Namespace ) if err != nil { return errors . Wrap ( err , " " ) } } err = cfg . SetActiveApplication ( appName , client . Namespace ) if err != nil { return errors . Wrap ( err , " " ) } return nil }
SetCurrent set application as active
SetCurrent set application as active
// also sets project to the given project // There might be a situation where application is not defined in local config // but it is present in OpenShift cluster. This situation can happen for example if user deleted config file. // In that case we need to add application back to the the config before we set it as active.