pkgcloudlib

package
v0.0.0-...-e7631cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package pkgcloud allows you to talk to the packagecloud API. See https://packagecloud.io/docs/api

Index

Constants

View Source
const ServiceBaseURL = "https://packagecloud.io/"

ServiceBaseURL - base URL for packagecloud

View Source
const ServiceURL = "https://packagecloud.io/api/v1"

ServiceURL is the URL of packagecloud's API.

View Source
const UserAgent = "pkgcloud Go client"

UserAgent identifier

Variables

This section is empty.

Functions

func ExtractPaginationHeaders

func ExtractPaginationHeaders(h *http.Header, p *Paginated) error

ExtractPaginationHeaders - Extract Paginated Object from the http.Headers

Types

type Client

type Client struct {
	URL   string `json:"url"`
	Token string `json:"token"`
}

A Client is a packagecloud client.

func NewClient

func NewClient(token string) (*Client, error)

NewClient creates a packagecloud client. API requests are authenticated using an API token. If no token is passed, it will be read from the PACKAGECLOUD_TOKEN environment variable.

func (Client) CreatePackage

func (c Client) CreatePackage(repo, distro, pkgFile string) error

CreatePackage pushes a new package to packagecloud.

func (Client) Destroy

func (c Client) Destroy(repo, packageFilename string) error

Destroy removes package from repository.

repo should be full path to repository (e.g. youruser/repository/ubuntu/xenial).

func (Client) DestroyFromPackage

func (c Client) DestroyFromPackage(p *Package) error

DestroyFromPackage removes package from repository.

For use with Package struct

func (*Client) Distributions

func (c *Client) Distributions() (*Distributions, error)

Distributions - retrieve all distribution descriptions

func (*Client) Exists

func (c *Client) Exists(repo, distro, packageFilename string) (bool, error)

Exists - Check to see if <repo>/<distro>/packageFilename exists in packagecloud.io

func (*Client) GetPaginatedPackages

func (c *Client) GetPaginatedPackages(endpoint string) (*PaginatedPackages, error)

GetPaginatedPackages - Gets the first set of PaginatedPackages for endpoint Note: Fetching subsequent packages should be done with PackaginesPackages.Next()

func (*Client) PaginatedAll

func (c *Client) PaginatedAll(repo string) (*PaginatedPackages, error)

PaginatedAll - Get the list of all Packages from a repo using PaginatedPackages The first PaginatedPackages object is the first page of responses. To get subsequent pages, call PaginatedPackages.Next() if it is non-nil

func (*Client) Promote

func (c *Client) Promote(p *Package, repo string) error

Promote - Promote Package to repo

func (*Client) SupportedDistros

func (c *Client) SupportedDistros() (map[string]int, error)

SupportedDistros - return a map of distro strings like "ubuntu/xenial" to distro ids.

type Distribution

type Distribution struct {
	DisplayName string `json:"display_name"`
	IndexName   string `json:"index_name"`
	Versions    []DistributionVersion
}

Distribution - struct to represent how packagecloud.io handles distributions https://packagecloud.io/docs/api#resource_distributions

type DistributionVersion

type DistributionVersion struct {
	ID          int    `json:"id"`
	DisplayName string `json:"display_name"`
	IndexName   string `json:"index_name"`
}

DistributionVersion - struct to represent how packagecloud.io handles distributions https://packagecloud.io/docs/api#resource_distributions

type Distributions

type Distributions struct {
	Deb []Distribution `json:"deb"`
	Dsc []Distribution `json:"dsc"`
	Rpm []Distribution `json:"rpm"`
}

Distributions - struct to represent how packagecloud.io handles distributions https://packagecloud.io/docs/api#resource_distributions

type Package

type Package struct {
	Name               string    `json:"name"`
	CreatedAt          time.Time `json:"created_at,string"`
	Epoch              int       `json:"epoch"`
	Scope              string    `json:"scope"`
	Private            bool      `json:"private"`
	UploaderName       string    `json:"uploader_name"`
	Indexed            bool      `json:"indexed"`
	RepositoryHTMLURL  string    `json:"repository_html_url"`
	DownloadDetailsURL string    `json:"downloads_detail_url"`
	DownloadSeriesURL  string    `json:"downloads_series_url"`
	DownloadCountURL   string    `json:"downloads_count_url"`
	PromoteURL         string    `json:"promote_url"`
	DestroyURL         string    `json:"destroy_url"`
	Filename           string    `json:"filename"`
	DistroVersion      string    `json:"distro_version"`
	Version            string    `json:"version"`
	Release            string    `json:"release"`
	Type               string    `json:"type"`
	PackageURL         string    `json:"package_url"`
	PackageHTMLURL     string    `json:"package_html_url"`
}

Package - packagcloud.io Package structure See for detailed description of fields: https://packagecloud.io/docs/api#object_PackageFragment

type Paginated

type Paginated struct {
	Total      int
	PerPage    int
	MaxPerPage int
}

Paginated captures pagination information described at - https://packagecloud.io/docs/api#pagination

type PaginatedPackages

type PaginatedPackages struct {
	Packages []*Package
	Next     func() (*PaginatedPackages, error)
	Paginated
}

PaginatedPackages captures 'Package' and pagination together Packages - list of packages returned in this page Next - function that can be called to fetch the nexts set of pages Paginated - Pagination meta data about this set of packages

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL