// Container retrieves a stow.Container based on its name which must be
// exact.
198138
func (l *location) Container(id string) (stow.Container, error) {
	client := l.client
	bucketRegion, _ := l.config.Config(ConfigRegion)

	// Endpoint would indicate that we are using s3-compatible storage, which
	// does not support s3session.GetBucketRegion().
	if endpoint, endpointSet := l.config.Config(ConfigEndpoint); !endpointSet && endpoint == "" {
		ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
		bucketRegion, _ = s3manager.GetBucketRegionWithClient(ctx, l.client, id)
		cancel()

		var err error
		client, _, err = newS3Client(l.config, bucketRegion)
		if err != nil {
			return nil, errors.Wrapf(err, "Container, creating new client for region: %s", bucketRegion)
		}
	}

	params := &s3.GetBucketLocationInput{
		Bucket: aws.String(id),
	}

	_, err := client.GetBucketLocation(params)
	if err != nil {
		if aerr, ok := err.(awserr.Error); ok && aerr.Code() == "NoSuchBucket" {
			return nil, stow.ErrNotFound
		}

		return nil, errors.Wrap(err, "GetBucketLocation")
	}

	c := &container{
		name:           id,
		client:         client,
		region:         bucketRegion,
		customEndpoint: l.customEndpoint,
	}

	return c, nil
}
674633
func (k *Key) Container() *Key {
	if len(k.pairs) == 2 {
		return nil
	}
	cont, err := k.set.Key(k.pairs[:len(k.pairs)-2]...)
	if err != nil {
		panic(err) // 'k' has been validated, all its components are thus also valid
	}
	return cont
}
227828
func (c *Connection) ContainersAll(opts *ContainersOpts) ([]Container, error) {
	opts = containersAllOpts(opts)
	containers := make([]Container, 0)
	for {
		newContainers, err := c.Containers(opts)
		if err != nil {
			return nil, err
		}
		containers = append(containers, newContainers...)
		if len(newContainers) < opts.Limit {
			break
		}
		opts.Marker = newContainers[len(newContainers)-1].Name
	}
	return containers, nil
}
344044
func (st *State) ContainerConfig() (result params.ContainerConfig, err error) {
	if st.facade.BestAPIVersion() < 6 {
		return st.containerConfigV5()
	}
	err = st.facade.FacadeCall("ContainerConfig", nil, &result)
	return result, err
}
135740
func (fhr FluxHelmRelease) Containers() []resource.Container {
	var containers []resource.Container
	// If there's an error in interpreting, return what we have.
	_ = FindFluxHelmReleaseContainers(fhr.Spec.Values, func(container string, image image.Ref, _ ImageSetter) error {
		containers = append(containers, resource.Container{
			Name:  container,
			Image: image,
		})
		return nil
	})
	return containers
}
1061902
func (daemon *Daemon) load(id string) (*container.Container, error) {
	container := daemon.newBaseContainer(id)

	if err := container.FromDisk(); err != nil {
		return nil, err
	}
	if err := label.ReserveLabel(container.ProcessLabel); err != nil {
		return nil, err
	}

	if container.ID != id {
		return container, fmt.Errorf("Container %s is stored at %s", container.ID, id)
	}

	return container, nil
}
1067134
func (b *Builder) Build() Container {
	if err := checkScopes(b.scopes); err != nil {
		return nil
	}

	defs := b.Definitions()

	for name, def := range defs {
		if def.Scope == "" {
			def.Scope = b.scopes[0]
			defs[name] = def
		}
	}

	return &container{
		containerCore: &containerCore{
			scopes:      b.scopes,
			scope:       b.scopes[0],
			definitions: defs,
			parent:      nil,
			children:    map[*containerCore]struct{}{},
			objects:     map[string]interface{}{},
		},
	}
}
1288976
func (docker *Docker) Container(image string) *Docker {
	docker.Image = image
	return docker
}
555527
func (p *Project) Containers(ctx context.Context, filter Filter, services ...string) ([]string, error) {
	containers := []string{}
	var lock sync.Mutex

	err := p.forEach(services, wrapperAction(func(wrapper *serviceWrapper, wrappers map[string]*serviceWrapper) {
		wrapper.Do(nil, events.NoEvent, events.NoEvent, func(service Service) error {
			serviceContainers, innerErr := service.Containers(ctx)
			if innerErr != nil {
				return innerErr
			}

			for _, container := range serviceContainers {
				running := container.IsRunning(ctx)
				switch filter.State {
				case Running:
					if !running {
						continue
					}
				case Stopped:
					if running {
						continue
					}
				case AnyState:
					// Don't do a thing
				default:
					// Invalid state filter
					return fmt.Errorf("Invalid container filter: %s", filter.State)
				}
				containerID := container.ID()
				lock.Lock()
				containers = append(containers, containerID)
				lock.Unlock()
			}
			return nil
		})
	}), nil)
	if err != nil {
		return nil, err
	}
	return containers, nil
}
633597
func (c *Container) Item(id string) (stow.Item, error) {
	res, err := c.client.Objects.Get(c.name, id).Do()
	if err != nil {
		return nil, stow.ErrNotFound
	}

	t, err := time.Parse(time.RFC3339, res.Updated)
	if err != nil {
		return nil, err
	}

	u, err := prepUrl(res.MediaLink)
	if err != nil {
		return nil, err
	}

	mdParsed, err := parseMetadata(res.Metadata)
	if err != nil {
		return nil, err
	}

	i := &Item{
		name:         id,
		container:    c,
		client:       c.client,
		size:         int64(res.Size),
		etag:         res.Etag,
		hash:         res.Md5Hash,
		lastModified: t,
		url:          u,
		metadata:     mdParsed,
		object:       res,
	}

	return i, nil
}
528937
func (l *Location) CreateContainer(containerName string) (stow.Container, error) {

	projId, _ := l.config.Config(ConfigProjectId)
	// Create a bucket.
	_, err := l.client.Buckets.Insert(projId, &storage.Bucket{Name: containerName}).Do()
	//res, err := l.client.Buckets.Insert(projId, &storage.Bucket{Name: containerName}).Do()
	if err != nil {
		return nil, err
	}

	newContainer := &Container{
		name:   containerName,
		client: l.client,
	}

	return newContainer, nil
}
883383
func (c *Container) Clone() *Container {
	vj := *c
	if vj.next != nil {
		vj.next = vj.next.Clone()
	}
	return &vj
}
287498
func (m *ContainerCreate_Runtime) Field(fieldpath []string) (string, bool) {
	if len(fieldpath) == 0 {
		return "", false
	}

	switch fieldpath[0] {
	case "name":
		return string(m.Name), len(m.Name) > 0
	case "options":
		decoded, err := github_com_containerd_typeurl.UnmarshalAny(m.Options)
		if err != nil {
			return "", false
		}

		adaptor, ok := decoded.(interface{ Field([]string) (string, bool) })
		if !ok {
			return "", false
		}
		return adaptor.Field(fieldpath[1:])
	}
	return "", false
}
762487
func (_m *APIClient) ContainerTop(ctx context.Context, _a1 string, arguments []string) (container.ContainerTopOKBody, error) {
	ret := _m.Called(ctx, _a1, arguments)

	var r0 container.ContainerTopOKBody
	if rf, ok := ret.Get(0).(func(context.Context, string, []string) container.ContainerTopOKBody); ok {
		r0 = rf(ctx, _a1, arguments)
	} else {
		r0 = ret.Get(0).(container.ContainerTopOKBody)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(context.Context, string, []string) error); ok {
		r1 = rf(ctx, _a1, arguments)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
1287233
func NewContainer() *Container {
	statsHit("NewContainer")
	c := &Container{typ: containerArray, len: 0, cap: stashedArraySize}
	c.pointer = (*uint16)(unsafe.Pointer(&c.data[0]))
	return c
}
44933
func (m *MockAPICalls) ContainerConfig() (params.ContainerConfig, error) {
	ret := m.ctrl.Call(m, "ContainerConfig")
	ret0, _ := ret[0].(params.ContainerConfig)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
1141573
func (rc *runContainer16) equals(o container) bool {
	srb, ok := o.(*runContainer16)

	if !ok {
		// maybe value instead of pointer
		val, valok := o.(*runContainer16)
		if valok {
			srb = val
			ok = true
		}
	}
	if ok {
		// Check if the containers are the same object.
		if rc == srb {
			return true
		}

		if len(srb.iv) != len(rc.iv) {
			return false
		}

		for i, v := range rc.iv {
			if v != srb.iv[i] {
				return false
			}
		}
		return true
	}

	// use generic comparison
	if o.getCardinality() != rc.getCardinality() {
		return false
	}
	rit := rc.getShortIterator()
	bit := o.getShortIterator()

	//k := 0
	for rit.hasNext() {
		if bit.next() != rit.next() {
			return false
		}
		//k++
	}
	return true
}