Пример #1
0
func deleteStepLib(c *cli.Context) error {
	// Input validation
	collectionURI := c.String(CollectionKey)
	if collectionURI == "" {
		return fmt.Errorf("Missing required input: collection")
	}

	log.Infof("Delete StepLib: %s", collectionURI)

	route, found := stepman.ReadRoute(collectionURI)
	if !found {
		log.Warnf("No route found for collection: %s, cleaning up routing..", collectionURI)
		if err := stepman.CleanupDanglingLib(collectionURI); err != nil {
			log.Errorf("Error cleaning up lib: %s", collectionURI)
		}
		log.Infof("Call 'stepman setup -c %s' for a clean setup", collectionURI)
		return nil
	}

	if err := stepman.CleanupRoute(route); err != nil {
		return fmt.Errorf("Failed to cleanup route for StepLib: %s", collectionURI)
	}

	return nil
}
Пример #2
0
func updateCollection(steplibSource string) (models.StepCollectionModel, error) {
	route, found := stepman.ReadRoute(steplibSource)
	if !found {
		log.Warnf("No route found for collection: %s, cleaning up routing..", steplibSource)
		if err := stepman.CleanupDanglingLib(steplibSource); err != nil {
			log.Errorf("Error cleaning up lib: %s", steplibSource)
		}
		log.Infof("Call 'stepman setup -c %s' for a clean setup", steplibSource)
		return models.StepCollectionModel{}, fmt.Errorf("No route found for StepLib: %s", steplibSource)
	}

	isLocalSteplib := strings.HasPrefix(steplibSource, "file://")

	if isLocalSteplib {
		if err := stepman.CleanupRoute(route); err != nil {
			return models.StepCollectionModel{}, fmt.Errorf("Failed to cleanup route for StepLib: %s", steplibSource)
		}

		if err := setupSteplib(steplibSource, false); err != nil {
			return models.StepCollectionModel{}, fmt.Errorf("Failed to setup StepLib: %s", steplibSource)
		}
	} else {
		pth := stepman.GetCollectionBaseDirPath(route)
		if exists, err := pathutil.IsPathExists(pth); err != nil {
			return models.StepCollectionModel{}, err
		} else if !exists {
			return models.StepCollectionModel{}, errors.New("Not initialized")
		}

		gitPullErr := retry.Times(2).Wait(3 * time.Second).Try(func(attempt uint) error {
			if attempt > 0 {
				log.Infoln("Retrying ...")
			}
			return cmdex.GitPull(pth)
		})
		if gitPullErr != nil {
			return models.StepCollectionModel{}, fmt.Errorf("Failed to update StepLib git repository, error: %s", gitPullErr)
		}

		if err := stepman.ReGenerateStepSpec(route); err != nil {
			return models.StepCollectionModel{}, err
		}
	}

	return stepman.ReadStepSpec(steplibSource)
}
Пример #3
0
func deleteCollection(c *cli.Context) {
	log.Debugln("[STEPMAN] - Delete collection")

	// Input validation
	collectionURI := c.String(CollectionKey)
	if collectionURI == "" {
		log.Fatalln("[STEPMAN] - No step collection specified")
	}

	route, found := stepman.ReadRoute(collectionURI)
	if !found {
		log.Warnf("No route found for collection: %s, cleaning up routing..", collectionURI)
		if err := stepman.CleanupDanglingLib(collectionURI); err != nil {
			log.Errorf("Error cleaning up lib: %s", collectionURI)
		}
		log.Infof("Call 'stepman setup -c %s' for a clean setup", collectionURI)
		return
	}

	if err := stepman.CleanupRoute(route); err != nil {
		log.Errorf("Failed to cleanup route for uri: %s", collectionURI)
	}
}