mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-04 15:04:25 +01:00
packaging: merge packaging repository
git-subtree-dir: tools/packaging git-subtree-mainline:f818b46a41git-subtree-split:1f22d72d5dSigned-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
69
tools/packaging/cmd/kata-pkgsync/cli/packagecloud.go
Normal file
69
tools/packaging/cmd/kata-pkgsync/cli/packagecloud.go
Normal file
@@ -0,0 +1,69 @@
|
||||
// Copyright (c) 2017-2018 Intel Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"path"
|
||||
|
||||
"github.com/mlafeldt/pkgcloud"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type PCClient struct {
|
||||
*pkgcloud.Client
|
||||
Repo string
|
||||
}
|
||||
|
||||
func (pc *PCClient) PackagecloudClient(user string, token string, repo string) error {
|
||||
client, err := pkgcloud.NewClient(token)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*pc = PCClient{client, path.Join(user, repo)}
|
||||
pc.ShowProgress(true)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pc PCClient) PackagecloudList() ([]pkgcloud.Package, error) {
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"repo": pc.Repo,
|
||||
}).Debug("Packagecloud listing package(s)")
|
||||
return pc.All(pc.Repo)
|
||||
}
|
||||
|
||||
func (pc PCClient) PackagecloudSearchPackage(pkg string) ([]pkgcloud.Package, error) {
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"repo": pc.Repo,
|
||||
"pkg": pkg,
|
||||
}).Debug("Packagecloud searching package")
|
||||
return pc.Search(pc.Repo, pkg, "", "", 0)
|
||||
}
|
||||
|
||||
func (pc PCClient) PackagecloudPush(packages []string, distro string) error {
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"repo": pc.Repo,
|
||||
"#": len(packages),
|
||||
"distro": distro,
|
||||
}).Debug("Packagecloud pushing package")
|
||||
for _, pkg := range packages {
|
||||
if err := pc.CreatePackage(pc.Repo, distro, pkg); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pc PCClient) PackagecloudDelete(filename string, distro string) error {
|
||||
logrus.WithFields(logrus.Fields{
|
||||
"repo": pc.Repo,
|
||||
"filename": filename,
|
||||
"distro": distro,
|
||||
}).Debug("Packagecloud delete package")
|
||||
return pc.Destroy(pc.Repo, path.Join(distro, filename))
|
||||
}
|
||||
Reference in New Issue
Block a user