Example #1
0
File: main.go Project: rhettg/ftl
func listRemotePackagesCmd(remote *ftl.RemoteRepository) error {
	packageList, err := remote.ListPackages()
	if err != nil {
		return err
	}
	for _, revision := range packageList {
		fmt.Println(revision)
	}
	return nil
}
Example #2
0
File: main.go Project: rhettg/ftl
func downloadPackageRevision(remote *ftl.RemoteRepository, local *ftl.LocalRepository, revision *ftl.RevisionInfo) error {
	fileName, r, err := remote.GetRevisionReader(revision)
	if err != nil {
		return fmt.Errorf("Failed listing: %v", err)
	}
	if r != nil {
		defer r.Close()
	}

	err = local.Add(revision, fileName, r)
	if err != nil {
		return fmt.Errorf("Failed adding %s: %v", revision.Name(), err)
	}
	return nil
}
Example #3
0
File: main.go Project: rhettg/ftl
func spoolCmd(rr *ftl.RemoteRepository, fileName string) error {
	file, err := os.Open(fileName)
	if err != nil {
		return fmt.Errorf("Error opening file: %v", err)
	}

	defer file.Close()

	name := filepath.Base(fileName)
	parts := strings.Split(name, ".")
	packageName := parts[0]

	revision, err := rr.Spool(packageName, file)
	if err != nil {
		return fmt.Errorf("Failed to spool: %v", err)
	}

	fmt.Println(revision.Name())
	return nil
}
Example #4
0
File: main.go Project: rhettg/ftl
func listRemoteCmd(rr *ftl.RemoteRepository, packageName string) error {
	activeRev, err := rr.GetCurrentRevision(packageName)
	if err != nil {
		return err
	}

	revisionList, err := rr.ListRevisions(packageName)
	if err != nil {
		return err
	}

	for _, revision := range revisionList {
		if activeRev != nil && *activeRev == *revision {
			fmt.Printf("%s\t(active)\n", revision.Name())
		} else {
			fmt.Println(revision.Name())
		}
	}

	return nil
}
Example #5
0
File: main.go Project: rhettg/ftl
func retrieveRemoteRevisions(r *ftl.RemoteRepository, packageName string) (curRev, prevRev *ftl.RevisionInfo, revisions []*ftl.RevisionInfo, err error) {
	crChan := make(chan ftl.RevisionListResult)
	go func() {
		currentRev, err := r.GetCurrentRevision(packageName)
		crChan <- ftl.RevisionListResult{[]*ftl.RevisionInfo{currentRev}, err}
	}()

	prChan := make(chan ftl.RevisionListResult)
	go func() {
		previousRev, err := r.GetPreviousRevision(packageName)
		prChan <- ftl.RevisionListResult{[]*ftl.RevisionInfo{previousRev}, err}
	}()

	rrChan := make(chan ftl.RevisionListResult)
	go func() {
		remoteRevisions, err := r.ListRevisions(packageName)
		rrChan <- ftl.RevisionListResult{remoteRevisions, err}
	}()

	crResult := <-crChan
	if crResult.Err != nil {
		err = fmt.Errorf("Failed to retrieve current revision")
	} else {
		curRev = crResult.Revisions[0]
	}

	prResult := <-prChan
	if prResult.Err != nil {
		err = fmt.Errorf("Failed to retrieve previous revision")
	} else {
		prevRev = prResult.Revisions[0]
	}

	rrResult := <-rrChan
	if rrResult.Err != nil {
		err = fmt.Errorf("Failed to retrieve remote revisions")
	} else {
		revisions = rrResult.Revisions
	}

	return
}