Exemplo n.º 1
0
func (d *tracedDeployer) Deploy(ctx context.Context, p events.Deployment, w io.Writer) (err error) {
	ctx, done := trace.Trace(ctx)
	err = d.deployer.Deploy(ctx, p, w)
	done(err, "Deploy",
		"repository", p.Repository.FullName,
		"creator", p.Deployment.Creator.Login,
		"ref", p.Deployment.Ref,
		"sha", p.Deployment.Sha,
	)
	return err
}
Exemplo n.º 2
0
Arquivo: ecs.go Projeto: brianz/empire
func (c *ecsClient) RegisterTaskDefinition(ctx context.Context, input *ecs.RegisterTaskDefinitionInput) (*ecs.RegisterTaskDefinitionOutput, error) {
	if c.tdThrottle == nil {
		// Only allow 1 task definition per second.
		c.tdThrottle = time.NewTicker(time.Second)
	}

	<-c.tdThrottle.C

	ctx, done := trace.Trace(ctx)
	resp, err := c.ECS.RegisterTaskDefinition(input)
	done(err, "RegisterTaskDefinition", "family", stringField(input.Family))
	return resp, err
}
Exemplo n.º 3
0
// TraceDeploy wraps a Deployer to perform tracing with package trace.
func TraceDeploy(d Deployer) Deployer {
	return DeployerFunc(func(ctx context.Context, event events.Deployment, w io.Writer) (err error) {
		ctx, done := trace.Trace(ctx)
		err = d.Deploy(ctx, event, w)
		done(err, "Deploy",
			"repository", event.Repository.FullName,
			"creator", event.Deployment.Creator.Login,
			"ref", event.Deployment.Ref,
			"sha", event.Deployment.Sha,
		)
		return err
	})
}
Exemplo n.º 4
0
// PullImage wraps the docker clients PullImage to handle authentication.
func (c *Client) PullImage(ctx context.Context, opts docker.PullImageOptions) error {
	var a docker.AuthConfiguration

	reg := opts.Registry

	if reg == "" {
		reg = "https://index.docker.io/v1/"
	}

	if c, ok := c.Auth.Configs[reg]; ok {
		a = c
	}

	ctx, done := trace.Trace(ctx)
	err := c.Client.PullImage(opts, a)
	done(err, "PullImage", "registry", opts.Registry, "repository", opts.Repository, "tag", opts.Tag)
	return err
}
Exemplo n.º 5
0
// PullImage wraps the docker clients PullImage to handle authentication.
func (c *Client) PullImage(ctx context.Context, opts docker.PullImageOptions) error {
	// This is to workaround an issue in the Docker API, where it doesn't
	// respect the registry param. We have to put the registry in the
	// repository field.
	if opts.Registry != "" {
		opts.Repository = fmt.Sprintf("%s/%s", opts.Registry, opts.Repository)
	}

	authConf, err := authConfiguration(c.AuthProvider, opts.Registry)
	if err != nil {
		return err
	}

	ctx, done := trace.Trace(ctx)
	err = c.Client.PullImage(opts, authConf)
	done(err, "PullImage", "registry", opts.Registry, "repository", opts.Repository, "tag", opts.Tag)
	return err
}
Exemplo n.º 6
0
Arquivo: ecs.go Projeto: brianz/empire
func (c *ecsClient) ListServicesPages(ctx context.Context, input *ecs.ListServicesInput, fn func(*ecs.ListServicesOutput, bool) bool) error {
	ctx, done := trace.Trace(ctx)
	err := c.ECS.ListServicesPages(input, fn)
	done(err, "ListServicesPages")
	return err
}
Exemplo n.º 7
0
Arquivo: ecs.go Projeto: brianz/empire
func (c *ecsClient) DescribeTaskDefinition(ctx context.Context, input *ecs.DescribeTaskDefinitionInput) (*ecs.DescribeTaskDefinitionOutput, error) {
	ctx, done := trace.Trace(ctx)
	resp, err := c.ECS.DescribeTaskDefinition(input)
	done(err, "DescribeTaskDefinition", "task-definition", stringField(input.TaskDefinition))
	return resp, err
}
Exemplo n.º 8
0
Arquivo: ecs.go Projeto: brianz/empire
func (c *ecsClient) UpdateService(ctx context.Context, input *ecs.UpdateServiceInput) (*ecs.UpdateServiceOutput, error) {
	ctx, done := trace.Trace(ctx)
	resp, err := c.ECS.UpdateService(input)
	done(err, "UpdateService", "service-name", stringField(input.Service), "desired-count", intField(input.DesiredCount), "task-definition", stringField(input.TaskDefinition))
	return resp, err
}
Exemplo n.º 9
0
func (c *ecsClient) ListServices(ctx context.Context, input *ecs.ListServicesInput) (*ecs.ListServicesOutput, error) {
	ctx, done := trace.Trace(ctx)
	resp, err := c.ECS.ListServices(input)
	done(err, "ListServices", "services", len(resp.ServiceARNs))
	return resp, err
}
Exemplo n.º 10
0
func (c *Client) StartContainer(ctx context.Context, id string, config *docker.HostConfig) error {
	ctx, done := trace.Trace(ctx)
	err := c.Client.StartContainer(id, config)
	done(err, "StartContainer", "id", id)
	return err
}
Exemplo n.º 11
0
Arquivo: ecs.go Projeto: brianz/empire
func (c *ecsClient) describeTasks(ctx context.Context, input *ecs.DescribeTasksInput) (*ecs.DescribeTasksOutput, error) {
	ctx, done := trace.Trace(ctx)
	resp, err := c.ECS.DescribeTasks(input)
	done(err, "DescribeTasks", "tasks", len(input.Tasks))
	return resp, err
}
Exemplo n.º 12
0
Arquivo: ecs.go Projeto: brianz/empire
func (c *ecsClient) DescribeServices(ctx context.Context, input *ecs.DescribeServicesInput) (*ecs.DescribeServicesOutput, error) {
	ctx, done := trace.Trace(ctx)
	resp, err := c.ECS.DescribeServices(input)
	done(err, "DescribeServices", "services", len(input.Services))
	return resp, err
}
Exemplo n.º 13
0
func (c *Client) RemoveContainer(ctx context.Context, opts docker.RemoveContainerOptions) error {
	ctx, done := trace.Trace(ctx)
	err := c.Client.RemoveContainer(opts)
	done(err, "RemoveContainer", "id", opts.ID)
	return err
}
Exemplo n.º 14
0
func ping(ctx context.Context) (err error) {
	ctx, done := trace.Trace(ctx)
	defer done(nil, "pong")

	return
}
Exemplo n.º 15
0
Arquivo: ecs.go Projeto: brianz/empire
func (c *ecsClient) StopTask(ctx context.Context, input *ecs.StopTaskInput) (*ecs.StopTaskOutput, error) {
	ctx, done := trace.Trace(ctx)
	resp, err := c.ECS.StopTask(input)
	done(err, "StopTask", "task", stringField(input.Task))
	return resp, err
}
Exemplo n.º 16
0
func (c *Client) StopContainer(ctx context.Context, id string, timeout uint) error {
	ctx, done := trace.Trace(ctx)
	err := c.Client.StopContainer(id, timeout)
	done(err, "StopContainer", "id", id, "timeout", timeout)
	return err
}
Exemplo n.º 17
0
Arquivo: ecs.go Projeto: brianz/empire
func (c *ecsClient) RunTask(ctx context.Context, input *ecs.RunTaskInput) (*ecs.RunTaskOutput, error) {
	ctx, done := trace.Trace(ctx)
	resp, err := c.ECS.RunTask(input)
	done(err, "RunTask", "taskDefinition", stringField(input.TaskDefinition))
	return resp, err
}
Exemplo n.º 18
0
func (c *Client) CreateContainer(ctx context.Context, opts docker.CreateContainerOptions) (*docker.Container, error) {
	ctx, done := trace.Trace(ctx)
	container, err := c.Client.CreateContainer(opts)
	done(err, "CreateContainer", "image", opts.Config.Image)
	return container, err
}
Exemplo n.º 19
0
Arquivo: ecs.go Projeto: brianz/empire
func (c *ecsClient) DeleteService(ctx context.Context, input *ecs.DeleteServiceInput) (*ecs.DeleteServiceOutput, error) {
	ctx, done := trace.Trace(ctx)
	resp, err := c.ECS.DeleteService(input)
	done(err, "DeleteService", "service-name", stringField(input.Service))
	return resp, err
}
Exemplo n.º 20
0
func (c *Client) AttachToContainer(ctx context.Context, opts docker.AttachToContainerOptions) error {
	ctx, done := trace.Trace(ctx)
	err := c.Client.AttachToContainer(opts)
	done(err, "AttachToContainer", "container", opts.Container)
	return err
}
Exemplo n.º 21
0
func (c *ecsClient) ListTasks(ctx context.Context, input *ecs.ListTasksInput) (*ecs.ListTasksOutput, error) {
	ctx, done := trace.Trace(ctx)
	resp, err := c.ECS.ListTasks(input)
	done(err, "ListTasks")
	return resp, err
}