imagespy

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2018 License: MIT Imports: 11 Imported by: 0

README

client-go

Usage

package main

import (
  "log"

  "github.com/imagespy/client-go"
)

func main() {
  client := imagespy.NewClientV2()
  img, err := client.Image.Get("golang:1.9.1")
  if err != nil {
    log.Fatal(err)
  }

  log.Println(img.LatestImage.Name)
  log.Println(img.LatestImage.Digest)
  log.Println(img.LatestImage.Tags)
}

Documentation

Index

Constants

View Source
const (
	// DefaultAPIEndpoint is the default endpoint of the ImageSpy API.
	DefaultAPIEndpoint = "https://imagespy.hydrantosaurus.com"
)

Variables

View Source
var DefaultRegistryWhitelist = map[string]struct{}{
	"index.docker.io": struct{}{},
	"docker.io":       struct{}{},
	"quay.io":         struct{}{},
}

Functions

This section is empty.

Types

type ClientV1

type ClientV1 struct {
	ImageSpy *ImageSpyService
	Layer    *LayerService
	// contains filtered or unexported fields
}

ClientV1 is the client for the Image Spy API version 1.

func NewClientV1

func NewClientV1() *ClientV1

NewClientV1 returns a new client for the V1 HTTP API.

func (*ClientV1) WithBaseURL

func (c *ClientV1) WithBaseURL(baseURL string) *ClientV1

WithBaseURL sets the base URL of the ImageSpy API.

func (*ClientV1) WithHTTPClient

func (c *ClientV1) WithHTTPClient(hc *http.Client) *ClientV1

WithHTTPClient sets the http.Client.

func (*ClientV1) WithRegistryWhitelist

func (c *ClientV1) WithRegistryWhitelist(whitelist map[string]struct{}) *ClientV1

WithRegistryWhitelist allows specifying the registries to send requests to.

func (*ClientV1) WithTimeout

func (c *ClientV1) WithTimeout(s string) *ClientV1

WithTimeout sets the timeout of the underlying http.Client.

type ClientV2 added in v0.3.0

type ClientV2 struct {
	Image *ImageServiceV2
	Layer *LayerServiceV2
	// contains filtered or unexported fields
}

func NewClientV2 added in v0.3.0

func NewClientV2() *ClientV2

NewClientV2 returns a new client for the V2 HTTP API.

func (*ClientV2) WithBaseURL added in v0.3.0

func (c *ClientV2) WithBaseURL(baseURL string) *ClientV2

WithBaseURL sets the base URL of the ImageSpy API.

func (*ClientV2) WithHTTPClient added in v0.3.0

func (c *ClientV2) WithHTTPClient(hc *http.Client) *ClientV2

WithHTTPClient sets the http.Client.

func (*ClientV2) WithTimeout added in v0.3.0

func (c *ClientV2) WithTimeout(s string) *ClientV2

WithTimeout sets the timeout of the underlying http.Client.

type Image

type Image struct {
	Created time.Time `json:"created"`
	Digest  string    `json:"digest"`
	Name    string    `json:"name"`
	Tag     string    `json:"tag"`
}

Image is a Docker image.

type ImageServiceV2 added in v0.3.0

type ImageServiceV2 struct {
	// contains filtered or unexported fields
}

ImageServiceV2 exposes the /v2/images API.

func (*ImageServiceV2) Get added in v0.3.0

func (i *ImageServiceV2) Get(ref string) (*ImageV2, error)

Get returns an Image.

type ImageSpy

type ImageSpy struct {
	CurrentImage *Image `json:"current_image"`
	LatestImage  *Image `json:"latest_image"`
	Name         string `json:"name"`
}

ImageSpy is a ImageSpy.

type ImageSpyError added in v0.2.1

type ImageSpyError struct {
	// contains filtered or unexported fields
}

ImageSpyError is the base error for all errors specific to this package.

func (*ImageSpyError) Error added in v0.2.1

func (e *ImageSpyError) Error() string

type ImageSpyService

type ImageSpyService struct {
	// contains filtered or unexported fields
}

ImageSpyService handles interactions.

func (*ImageSpyService) Get

func (is *ImageSpyService) Get(name string) (*ImageSpy, error)

Get retrieves an ImageSpy. Creates the ImageSpy if it does not exist.

type ImageV2 added in v0.3.0

type ImageV2 struct {
	Digest      string         `json:"digest"`
	LatestImage *LatestImageV2 `json:"latest_image"`
	Name        string         `json:"name"`
	Tags        []string       `json:"tags"`
}

ImageV2 is an Image of the V2 API.

type LatestImageV2 added in v0.3.0

type LatestImageV2 struct {
	Digest string   `json:"digest"`
	Name   string   `json:"name"`
	Tags   []string `json:"tags"`
}

LatestImageV2 is the latest image of an image.

type Layer added in v0.2.0

type Layer struct {
	Digest       string   `json:"digest"`
	SourceImages []*Image `json:"source_images"`
}

Layer is the digest of a layer and a list of images which created the layer.

type LayerService added in v0.2.0

type LayerService struct {
	// contains filtered or unexported fields
}

LayerService exposes the Layer API of the Image Spy API.

func (*LayerService) Get added in v0.2.0

func (ls *LayerService) Get(digest string) (*Layer, error)

Get retrieves a Layer.

type LayerServiceV2 added in v0.3.0

type LayerServiceV2 struct {
	// contains filtered or unexported fields
}

LayerServiceV2 exposes the /v2/images API.

func (*LayerServiceV2) Get added in v0.3.0

func (l *LayerServiceV2) Get(digest string) (*LayerV2, error)

Get returns a Layer.

type LayerV2 added in v0.3.0

type LayerV2 struct {
	Digest       string     `json:"digest"`
	SourceImages []*ImageV2 `json:"source_images"`
}

LayerV2 is a Layer of the V2 API.

type Logger

type Logger interface {
	Debug(args ...interface{})
}

Logger provides logging.

var Log Logger = &NullLogger{}

Log is used by this library to log messages.

type NotFoundError added in v0.2.1

type NotFoundError struct {
	ImageSpyError
	// contains filtered or unexported fields
}

NotFoundError indicates that a resource could not be found.

type NullLogger

type NullLogger struct{}

NullLogger is noop.

func (*NullLogger) Debug

func (l *NullLogger) Debug(args ...interface{})

Debug implements Logger.

Jump to

Keyboard shortcuts

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