docker

package
v0.85.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 10 Imported by: 0

README

HSP Docker

Go Reference

The docker client provides access to the HSDP Docker registry.

Example usage

The following example will create a console.Client and use it to create a docker.Client to list all namespaces and repositories in the us-east region:

package main

import (
	"context"
	"fmt"

	"github.com/philips-software/go-hsdp-api/console"
	"github.com/philips-software/go-hsdp-api/console/docker"
)

func main() {
	consoleClient, err := console.NewClient(nil, &console.Config{
		Region:   "us-east",
	})
	if err != nil {
		fmt.Printf("Error creating console client: %v\n", err)
	}
	err = consoleClient.Login("cfusernamehere", `cfpasswordhere`)
	if err != nil {
		fmt.Printf("Error logging into Console: %v\n", err)
		return
	}
	dockerClient, err := docker.NewClient(consoleClient, &docker.Config{
		Region:   "us-east",
	})
	if err != nil {
		fmt.Printf("Error creating docker client: %v\n", err)
	}
	ctx := context.Background()
	list, err := dockerClient.Namespaces.GetNamespaces(ctx)

	if err != nil {
		fmt.Printf("Error getting namespaces: %v\n", err)
		return
	}
	for _, namespace := range *list {
		fmt.Printf("------ Namespace: %s --------\n", namespace.ID)
		repos, err := dockerClient.Namespaces.GetRepositories(ctx, namespace.ID)
		if err != nil {
			fmt.Printf("Error fetching repo '%s': %v\n", namespace.ID, err)
			continue
		}
		for _, repo := range *repos {
			latest, err := dockerClient.Repositories.GetLatestTag(ctx, repo.ID)
			tag := ""
			digest := ""
			if err == nil {
				tag = ":" + latest.Name

			}
			fmt.Printf("Repo: %s/%s%s (%s)\n", namespace.ID, repo.Name, tag, digest)
		}
	}
}

Documentation

Overview

Package docker provides support for HSDP Docker Registry services

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// HTTP consoleClient used to communicate with IAM API
	*console.Client

	// User agent used when communicating with the HSDP DICOM API.
	UserAgent string

	ServiceKeys  *ServiceKeysService
	Namespaces   *NamespacesService
	Repositories *RepositoriesService
	// contains filtered or unexported fields
}

A Client manages communication with HSDP DICOM API

func NewClient

func NewClient(consoleClient *console.Client, config *Config) (*Client, error)

NewClient returns a new HSDP Docker Registry API client. A configured console client must be provided as the underlying API requires tokens from respective service

func (*Client) Close

func (c *Client) Close()

Close releases allocated resources of clients

func (*Client) Host added in v0.63.6

func (c *Client) Host() string

Host returns the regional host base

func (*Client) Query

func (c *Client) Query(ctx context.Context, q interface{}, variables map[string]interface{}) error

Query is a generic GraphQL query

type Config

type Config struct {
	Region       string
	DockerAPIURL string
	DebugLog     io.Writer
	// contains filtered or unexported fields
}

Config contains the configuration of a consoleClient

type Namespace

type Namespace struct {
	ID           string                   `json:"id"`
	IsPublic     bool                     `json:"isPublic"`
	CreatedAt    time.Time                `json:"createdAt"`
	IsOrgSpaceID bool                     `json:"isOrgSpaceId"`
	NumRepos     int                      `json:"numRepos"`
	UserAccess   UserNamespaceAccessInput `json:"userAccess"`
}

type NamespaceAccess

type NamespaceAccess struct {
	ID int `json:"id"`
	UserNamespaceAccessInput
}

type NamespaceInput

type NamespaceInput struct {
	ID graphql.String `json:"id"`
}

type NamespaceUser

type NamespaceUser struct {
	ID              string          `json:"id"`
	Name            string          `json:"name"`
	Username        string          `json:"username"`
	NamespaceAccess NamespaceAccess `json:"namespaceAccess"`
}

type NamespaceUserResult

type NamespaceUserResult struct {
	ID     int    `json:"id"`
	UserID string `json:"userId"`
	UserNamespaceAccessInput
}

type NamespacesService

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

func (*NamespacesService) AddNamespaceUser

func (s *NamespacesService) AddNamespaceUser(ctx context.Context, namespaceID, username string, access UserNamespaceAccessInput) (*NamespaceUserResult, error)

func (*NamespacesService) CreateNamespace

func (s *NamespacesService) CreateNamespace(ctx context.Context, id string) (*Namespace, error)

func (*NamespacesService) DeleteNamespace

func (s *NamespacesService) DeleteNamespace(ctx context.Context, ns Namespace) error

func (*NamespacesService) DeleteNamespaceUser

func (s *NamespacesService) DeleteNamespaceUser(ctx context.Context, namespaceID, userId string) error

func (*NamespacesService) GetNamespaceByID

func (s *NamespacesService) GetNamespaceByID(ctx context.Context, id string) (*Namespace, error)

func (*NamespacesService) GetNamespaceUsers

func (s *NamespacesService) GetNamespaceUsers(ctx context.Context, ns Namespace) (*[]NamespaceUser, error)

func (*NamespacesService) GetNamespaces

func (s *NamespacesService) GetNamespaces(ctx context.Context) (*[]Namespace, error)

func (*NamespacesService) GetRepositories

func (s *NamespacesService) GetRepositories(ctx context.Context, namespaceId string) (*[]Repository, error)

func (*NamespacesService) UpdateNamespaceUserAccess added in v0.48.1

func (s *NamespacesService) UpdateNamespaceUserAccess(ctx context.Context, id int, access UserNamespaceAccessInput) error

type OptionFunc

type OptionFunc func(*http.Request) error

OptionFunc is the function signature function for options

type RepositoriesService

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

func (*RepositoriesService) CreateRepository

func (r *RepositoriesService) CreateRepository(ctx context.Context, repository RepositoryInput, details RepositoryDetailsInput) (*RepositoryResult, error)

func (*RepositoriesService) DeleteRepository

func (r *RepositoriesService) DeleteRepository(ctx context.Context, repository Repository) error

func (*RepositoriesService) GetLatestTag added in v0.51.1

func (r *RepositoriesService) GetLatestTag(ctx context.Context, repositoryId string) (*Tag, error)

GetLatestTag returns the tag that was most recently updated

func (*RepositoriesService) GetRepository

func (r *RepositoriesService) GetRepository(ctx context.Context, namespaceId, name string) (*Repository, error)

func (*RepositoriesService) GetTags

func (r *RepositoriesService) GetTags(ctx context.Context, repositoryId string) (*[]Tag, error)

func (*RepositoriesService) UpdateRepository

func (r *RepositoriesService) UpdateRepository(ctx context.Context, repository Repository, details RepositoryDetailsInput) (*RepositoryDetailsInput, error)

type Repository

type Repository struct {
	ID           string                 `json:"id"`
	NamespaceId  string                 `json:"namespaceId"`
	Name         string                 `json:"name"`
	NumPulls     int                    `json:"numPulls"`
	NumTags      int                    `json:"numTags"`
	LastPushedAt time.Time              `json:"lastPushedAt"`
	Details      RepositoryDetailsInput `json:"details"`
}

type RepositoryDetailsInput

type RepositoryDetailsInput struct {
	ShortDescription string `json:"shortDescription"`
	FullDescription  string `json:"fullDescription"`
}

type RepositoryInput

type RepositoryInput struct {
	NamespaceID string `json:"namespaceId"`
	Name        string `json:"name"`
}

type RepositoryResult

type RepositoryResult struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	NamespaceID string `json:"namespaceId"`
}

type ServiceKey

type ServiceKey struct {
	ID          int       `json:"id"`
	Description string    `json:"description"`
	Username    string    `json:"username"`
	Password    string    `json:"password"`
	CreatedAt   time.Time `json:"createdAt"`
}

type ServiceKeyNode

type ServiceKeyNode struct {
	ID          int       `json:"id"`
	Description string    `json:"description"`
	Username    string    `json:"username"`
	CreatedAt   time.Time `json:"createdAt"`
}

type ServiceKeysService

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

func (*ServiceKeysService) CreateServiceKey

func (a *ServiceKeysService) CreateServiceKey(ctx context.Context, description string) (*ServiceKey, error)

func (*ServiceKeysService) DeleteServiceKey

func (a *ServiceKeysService) DeleteServiceKey(ctx context.Context, key ServiceKey) error

func (*ServiceKeysService) GetServiceKeyByID

func (a *ServiceKeysService) GetServiceKeyByID(ctx context.Context, id int) (*ServiceKeyNode, error)

func (*ServiceKeysService) GetServiceKeys

func (a *ServiceKeysService) GetServiceKeys(ctx context.Context) (*[]ServiceKeyNode, error)

type Tag

type Tag struct {
	ID             int       `json:"id"`
	Name           string    `json:"name"`
	CompressedSize int       `json:"compressedSize"`
	UpdatedAt      time.Time `json:"updatedAt"`
	NumPulls       int       `json:"numPulls"`
	Digest         string    `json:"digest"`
	ImageId        string    `json:"imageId"`
}

type UpdateUserNamespacesAccessInput added in v0.48.1

type UpdateUserNamespacesAccessInput struct {
	ID int `json:"id"`
	UserNamespaceAccessInput
}

type UserNamespaceAccessInput

type UserNamespaceAccessInput struct {
	CanPull   bool `json:"canPull"`
	CanPush   bool `json:"canPush"`
	CanDelete bool `json:"canDelete"`
	IsAdmin   bool `json:"isAdmin"`
}

Jump to

Keyboard shortcuts

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