cs

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package cs implements features related to Lightsail (C)ontainer (S)ervice.

Example (SkipStatuses)
r := skipStatuses(
	strings.NewReader(`
		{"status": "keep me"}
		{"status": "xyz skip1 abc"}
		{"status": "also keep me!"}
		{"status": "\tskip2"}`),
	"skip2", "skip1",
)
if _, err := io.Copy(os.Stdout, r); err != nil {
	fmt.Println(err)
	return
}
Output:

{"status":"keep me"}
{"status":"also keep me!"}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func PushImage

PushImage pushes and registers the image to Lightsail service registry.

Example
defer func() {
	testNow, testRngReader = nil, nil
}()
testNow = func() time.Time { return time.Unix(1611796436, 0) }
testRngReader = strings.NewReader("abcdefgh")

ctx := context.Background()
fls := &fakeLightsailImageOperator{}
fimgo := &fakeImageOperator{}
if err := PushImage(ctx, &PushImageInput{Service: "doge", Image: "nginx:latest", Label: "www"}, fls, fimgo); err != nil {
	fmt.Println(err)
	return
}
fmt.Println("docker engine call log:")
for _, s := range fimgo.log {
	fmt.Println(" ", s)
}
fmt.Println("lightsail api call log:")
for _, s := range fls.log {
	fmt.Println(" ", s)
}
Output:

Digest: sha256:10b8cc432d56da8b61b070f4c7d2543a9ed17c2b23010b43af434fd40e2ca4aa
Image "nginx:latest" registered.
Refer to this image as ":doge.www.12345" in deployments.
docker engine call log:
  tag "nginx:latest" as "123456789012.dkr.ecr.so-fake-2.amazonaws.com/sr:1611796436000000000-c5h66p35cpjmg"
  push "123456789012.dkr.ecr.so-fake-2.amazonaws.com/sr:1611796436000000000-c5h66p35cpjmg"
  untag "123456789012.dkr.ecr.so-fake-2.amazonaws.com/sr:1611796436000000000-c5h66p35cpjmg"
lightsail api call log:
  create login
  register (doge, www, sha256:10b8cc432d56da8b61b070f4c7d2543a9ed17c2b23010b43af434fd40e2ca4aa)

Types

type DockerEngine

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

DockerEngine defines a subset of client-side operations against local Docker Engine, relevant to lightsailctl.

func NewDockerEngine

func NewDockerEngine(ctx context.Context) (*DockerEngine, error)

func (*DockerEngine) PushImage

func (e *DockerEngine) PushImage(ctx context.Context, remoteImage RemoteImage) (digest string, err error)

func (*DockerEngine) TagImage

func (e *DockerEngine) TagImage(ctx context.Context, source, target string) error

func (*DockerEngine) UntagImage

func (e *DockerEngine) UntagImage(ctx context.Context, image string) error

type ImageOperator

type ImageOperator interface {
	TagImage(ctx context.Context, source, target string) error
	UntagImage(ctx context.Context, image string) error
	PushImage(ctx context.Context, r RemoteImage) (digest string, err error)
}

type LightsailImageOperator

type LightsailImageOperator interface {
	RegistryLoginCreator

	RegisterContainerImage(
		context.Context,
		*lightsail.RegisterContainerImageInput,
		...func(*lightsail.Options),
	) (*lightsail.RegisterContainerImageOutput, error)
}

type PushImageInput

type PushImageInput struct {
	Service string
	Image   string
	Label   string
}

type RegistryLoginCreator

type RegistryLoginCreator interface {
	CreateContainerServiceRegistryLogin(
		context.Context,
		*lightsail.CreateContainerServiceRegistryLoginInput,
		...func(*lightsail.Options),
	) (*lightsail.CreateContainerServiceRegistryLoginOutput, error)
}

type RemoteImage

type RemoteImage struct {
	registry.AuthConfig
	Tag string
}

RemoteImage combines remote server auth details, address and an image tag into a value that has everything that one needs to push this image to a remote repo.

func (*RemoteImage) Ref

func (r *RemoteImage) Ref() string

Jump to

Keyboard shortcuts

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