metadata

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Overview

Package metadata provides methods to deal with a metadata container server.

In order to imitate the GCE environment to provide credentials and some other project metadata, we run a metadata service container and make it available to build steps as metadata.google.internal, metadata, and the fixed IP 169.254.169.254.

The GCE metadata service is documented here:

https://cloud.google.com/compute/docs/storing-retrieving-metadata

The imitation metadata service we run offers a subset of the true metadata functionality, focused on providing credentials to client libraries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanCloudbuildNetwork added in v0.1.1

func CleanCloudbuildNetwork(ctx context.Context, r runner.Runner) error

CleanCloudbuildNetwork delete the cloudbuild network.

func CreateCloudbuildNetwork added in v0.1.1

func CreateCloudbuildNetwork(ctx context.Context, r runner.Runner, subnet string) error

CreateCloudbuildNetwork creates a cloud build network to link the build builds.

func StartCloudServer added in v0.0.5

func StartCloudServer(ctx context.Context, r runner.Runner, metadataImage string) error

StartCloudServer starts the metadata server container for VMs running as part of the Cloud Build service.

This version of Start*Server needs to make iptables rules that we don't want (or need) on a user's local machine.

The container listens on local port 8082, which is where RealUpdater POSTs to.

func StartLocalServer added in v0.0.5

func StartLocalServer(ctx context.Context, r runner.Runner, metadataImage string) error

StartLocalServer starts the metadata server container for VMs running as part of the Cloud Build service.

This version of Start*Server does not update iptables.

The container listens on local port 8082, which is where RealUpdater POSTs to.

Types

type ProjectInfo

type ProjectInfo struct {
	ProjectID  string `json:"project_id"`
	ProjectNum int64  `json:"project_num"`
}

ProjectInfo represents an incoming build request containing the project ID and number to make available as metadata.

type RealUpdater

type RealUpdater struct {
	Local bool
}

RealUpdater actually sends POST requests to update spoofed metadata.

func (RealUpdater) SetProjectInfo

func (r RealUpdater) SetProjectInfo(b ProjectInfo) error

SetProjectInfo updates the spoofed metadata server's project information.

func (RealUpdater) SetToken

func (r RealUpdater) SetToken(tok *Token) error

SetToken updates the spoofed metadata server's credentials.

func (RealUpdater) Stop

Stop stops the metadata server container and tears down the docker cloudbuild network used to route traffic to it. Try to clean both the container and the network before returning an error.

type Token

type Token struct {
	AccessToken string    `json:"access_token"`
	Expiry      time.Time `json:"expiry"`
	Email       string    `json:"email"`
	Scopes      []string
}

Token represents an OAuth token including the access token, account email, expiration, and scopes.

func (Token) Oauth2 added in v0.2.2

func (t Token) Oauth2() *oauth2.Token

Oauth2 converts a Token to a standard oauth2.Token.

type Updater

type Updater interface {
	SetToken(*Token) error
	SetProjectInfo(ProjectInfo) error
}

Updater encapsulates updating the spoofed metadata server.

Jump to

Keyboard shortcuts

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