func do(
	packageCopier aptly_package_copier.PackageCopier,
	packageLatestVersion aptly_package_latest_version.PackageLatestVersion,
	packageDetailLatestLister aptly_model_latest_lister.PackageDetailLatestLister,
	repoURL string,
	apiURL string,
	apiUsername string,
	apiPassword string,
	apiPasswordfile string,
	sourceRepo string,
	targetRepo string,
	targetDistribution string,
	name string,
	version string,
) error {
	glog.Infof("repoURL: %v apiURL: %v apiUsername: %v apiPassword: %v apiPasswordfile: %v sourceRepo: %v targetRepo: %v targetDistribution: %v name: %v version: %v", repoURL, apiURL, apiUsername, apiPassword, apiPasswordfile, sourceRepo, targetRepo, targetDistribution, name, version)
	if len(apiPasswordfile) > 0 {
		content, err := ioutil.ReadFile(apiPasswordfile)
		if err != nil {
			return err
		}
		apiPassword = strings.TrimSpace(string(content))
	}
	if len(apiURL) == 0 {
		return fmt.Errorf("parameter %s missing", parameterAPIURL)
	}
	if len(sourceRepo) == 0 {
		return fmt.Errorf("parameter %s missing", parameterSource)
	}
	if len(targetRepo) == 0 {
		return fmt.Errorf("parameter %s missing", parameterTarget)
	}
	if len(name) == 0 {
		return fmt.Errorf("parameter %s missing", parameterName)
	}
	if len(version) == 0 {
		return fmt.Errorf("parameter %s missing", parameterVersion)
	}
	return copy(packageCopier, packageLatestVersion, packageDetailLatestLister, aptly_model.NewAPI(repoURL, apiURL, apiUsername, apiPassword), aptly_model.Repository(sourceRepo), aptly_model.Repository(targetRepo), aptly_model.Distribution(targetDistribution), aptly_model.Package(name), aptly_version.Version(version))
}
func do(
	repo_creater aptly_repo_creater.RepoCreater,
	repoURL string,
	apiURL string,
	apiUsername string,
	apiPassword string,
	apiPasswordfile string,
	repo string,
	distribution string,
	architectures []string,
) error {
	glog.Infof("repoURL: %v apiURL: %v apiUsername: %v apiPassword: %v apiPasswordfile: %v repo: %v distribution: %v architectures: %v", repoURL, apiURL, apiUsername, apiPassword, apiPasswordfile, repo, distribution, architectures)
	if len(apiPasswordfile) > 0 {
		content, err := ioutil.ReadFile(apiPasswordfile)
		if err != nil {
			return err
		}
		apiPassword = strings.TrimSpace(string(content))
	}
	if len(apiURL) == 0 {
		return fmt.Errorf("parameter %s missing", parameterAPIURL)
	}
	if len(repo) == 0 {
		return fmt.Errorf("parameter %s missing", parameterRepo)
	}
	return repo_creater.CreateRepo(aptly_model.NewAPI(repoURL, apiURL, apiUsername, apiPassword), aptly_model.Repository(repo), aptly_model.Distribution(distribution), aptly_model.ParseArchitectures(architectures))
}
Beispiel #3
0
func do(
	package_uploader aptly_package_uploader.PackageUploader,
	repoURL string,
	apiURL string,
	apiUsername string,
	apiPassword string,
	apiPasswordfile string,
	file string,
	repo string,
	distribution string,
) error {
	glog.Infof("repoURL: %v apiURL: %v apiUsername: %v apiPassword: %v apiPasswordfile: %v file: %v repo: %v distribution: %v", repoURL, apiURL, apiUsername, apiPassword, apiPasswordfile, file, repo, distribution)
	if len(apiPasswordfile) > 0 {
		content, err := ioutil.ReadFile(apiPasswordfile)
		if err != nil {
			return err
		}
		apiPassword = strings.TrimSpace(string(content))
	}
	if len(apiURL) == 0 {
		return fmt.Errorf("parameter %s missing", parameterAPIURL)
	}
	if len(repo) == 0 {
		return fmt.Errorf("parameter %s missing", parameterRepo)
	}
	if len(file) == 0 {
		return fmt.Errorf("parameter %s missing", parameterFile)
	}
	glog.V(2).Infof("upload file %s to repo %s dist %s on server %s", file, repo, distribution, apiURL)
	return package_uploader.UploadPackageByFile(aptly_model.NewAPI(repoURL, apiURL, apiUsername, apiPassword), aptly_model.Repository(repo), aptly_model.Distribution(distribution), file)
}
func do(
	writer io.Writer,
	packageLister aptly_package_lister.PackageLister,
	repoURL string,
	apiURL string,
	apiUsername string,
	apiPassword string,
	passwordfile string,
	repo string,
) error {
	glog.Infof("repoURL: %v apiURL: %v apiUsername: %v apiPassword: %v passwordfile: %v repo: %v", repoURL, apiURL, apiUsername, apiPassword, passwordfile, repo)
	if len(passwordfile) > 0 {
		content, err := ioutil.ReadFile(passwordfile)
		if err != nil {
			return err
		}
		apiPassword = strings.TrimSpace(string(content))
	}
	if len(apiURL) == 0 {
		return fmt.Errorf("parameter %s missing", parameterAPIURL)
	}
	if len(repo) == 0 {
		return fmt.Errorf("parameter %s missing", parameterRepo)
	}
	var err error
	var packages []map[string]string
	if packages, err = packageLister.ListPackages(aptly_model.NewAPI(repoURL, apiURL, apiUsername, apiPassword), aptly_model.Repository(repo)); err != nil {
		return err
	}
	for _, info := range packages {
		name := info["Package"]
		version := info["Version"]
		fmt.Fprintf(writer, "%s %s\n", name, version)
	}
	return nil
}
func do(
	writer io.Writer,
	packageVersions aptly_package_versions.PackageVersions,
	repoURL string,
	apiURL string,
	apiUsername string,
	apiPassword string,
	apiPasswordfile string,
	repo string,
	name string,
) error {
	glog.Infof("repoURL: %v apiURL: %v apiUsername: %v apiPassword: %v apiPasswordfile: %v repo: %v name: %v", repoURL, apiURL, apiUsername, apiPassword, apiPasswordfile, repo, name)
	if len(apiPasswordfile) > 0 {
		content, err := ioutil.ReadFile(apiPasswordfile)
		if err != nil {
			return err
		}
		apiPassword = strings.TrimSpace(string(content))
	}

	if len(apiURL) == 0 {
		return fmt.Errorf("parameter %s missing", parameterAPIURL)
	}
	if len(repo) == 0 {
		return fmt.Errorf("parameter %s missing", parameterRepo)
	}
	if len(name) == 0 {
		return fmt.Errorf("parameter %s missing", parameterName)
	}

	var err error
	var versions []aptly_version.Version
	if versions, err = packageVersions.PackageVersions(aptly_model.NewAPI(repoURL, apiURL, apiUsername, apiPassword), aptly_model.Repository(repo), aptly_model.Package(name)); err != nil {
		return err
	}
	if len(versions) == 0 {
		return fmt.Errorf("package %s not found", name)
	}
	sort.Sort(aptly_version.VersionByName(versions))
	fmt.Fprintf(writer, "%s\n", versions[len(versions)-1])
	return nil
}