-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prototype stripping containerd/containerd out
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
- Loading branch information
Showing
22 changed files
with
1,341 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
// Copyright 2017 Google Inc. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
/* | ||
Copyright The containerd Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package containers | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/gogo/protobuf/types" | ||
) | ||
|
||
// Container represents the set of data pinned by a container. Unless otherwise | ||
// noted, the resources here are considered in use by the container. | ||
// | ||
// The resources specified in this object are used to create tasks from the container. | ||
type Container struct { | ||
// ID uniquely identifies the container in a namespace. | ||
// | ||
// This property is required and cannot be changed after creation. | ||
ID string | ||
|
||
// Labels provide metadata extension for a container. | ||
// | ||
// These are optional and fully mutable. | ||
Labels map[string]string | ||
|
||
// Image specifies the image reference used for a container. | ||
// | ||
// This property is optional and mutable. | ||
Image string | ||
|
||
// Runtime specifies which runtime should be used when launching container | ||
// tasks. | ||
// | ||
// This property is required and immutable. | ||
Runtime RuntimeInfo | ||
|
||
// Spec should carry the runtime specification used to implement the | ||
// container. | ||
// | ||
// This field is required but mutable. | ||
Spec *types.Any | ||
|
||
// SnapshotKey specifies the snapshot key to use for the container's root | ||
// filesystem. When starting a task from this container, a caller should | ||
// look up the mounts from the snapshot service and include those on the | ||
// task create request. | ||
// | ||
// This field is not required but mutable. | ||
SnapshotKey string | ||
|
||
// Snapshotter specifies the snapshotter name used for rootfs | ||
// | ||
// This field is not required but immutable. | ||
Snapshotter string | ||
|
||
// CreatedAt is the time at which the container was created. | ||
CreatedAt time.Time | ||
|
||
// UpdatedAt is the time at which the container was updated. | ||
UpdatedAt time.Time | ||
|
||
// Extensions stores client-specified metadata | ||
Extensions map[string]types.Any | ||
} | ||
|
||
// RuntimeInfo holds runtime specific information | ||
type RuntimeInfo struct { | ||
Name string | ||
Options *types.Any | ||
} | ||
|
||
// Store interacts with the underlying container storage | ||
type Store interface { | ||
// Get a container using the id. | ||
// | ||
// Container object is returned on success. If the id is not known to the | ||
// store, an error will be returned. | ||
Get(ctx context.Context, id string) (Container, error) | ||
|
||
// List returns containers that match one or more of the provided filters. | ||
List(ctx context.Context, filters ...string) ([]Container, error) | ||
|
||
// Create a container in the store from the provided container. | ||
Create(ctx context.Context, container Container) (Container, error) | ||
|
||
// Update the container with the provided container object. ID must be set. | ||
// | ||
// If one or more fieldpaths are provided, only the field corresponding to | ||
// the fieldpaths will be mutated. | ||
Update(ctx context.Context, container Container, fieldpaths ...string) (Container, error) | ||
|
||
// Delete a container using the id. | ||
// | ||
// nil will be returned on success. If the container is not known to the | ||
// store, ErrNotFound will be returned. | ||
Delete(ctx context.Context, id string) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
// Copyright 2017 Google Inc. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
/* | ||
Copyright The containerd Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// Package errdefs defines the common errors used throughout containerd | ||
// packages. | ||
// | ||
// Use with errors.Wrap and error.Wrapf to add context to an error. | ||
// | ||
// To detect an error class, use the IsXXX functions to tell whether an error | ||
// is of a certain type. | ||
// | ||
// The functions ToGRPC and FromGRPC can be used to map server-side and | ||
// client-side errors to the correct types. | ||
package errdefs | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pkg/errors" | ||
) | ||
|
||
// Definitions of common error types used throughout containerd. All containerd | ||
// errors returned by most packages will map into one of these errors classes. | ||
// Packages should return errors of these types when they want to instruct a | ||
// client to take a particular action. | ||
// | ||
// For the most part, we just try to provide local grpc errors. Most conditions | ||
// map very well to those defined by grpc. | ||
var ( | ||
ErrUnknown = errors.New("unknown") // used internally to represent a missed mapping. | ||
ErrInvalidArgument = errors.New("invalid argument") | ||
ErrNotFound = errors.New("not found") | ||
ErrAlreadyExists = errors.New("already exists") | ||
ErrFailedPrecondition = errors.New("failed precondition") | ||
ErrUnavailable = errors.New("unavailable") | ||
ErrNotImplemented = errors.New("not implemented") // represents not supported and unimplemented | ||
) | ||
|
||
// IsInvalidArgument returns true if the error is due to an invalid argument | ||
func IsInvalidArgument(err error) bool { | ||
return errors.Is(err, ErrInvalidArgument) | ||
} | ||
|
||
// IsNotFound returns true if the error is due to a missing object | ||
func IsNotFound(err error) bool { | ||
return errors.Is(err, ErrNotFound) | ||
} | ||
|
||
// IsAlreadyExists returns true if the error is due to an already existing | ||
// metadata item | ||
func IsAlreadyExists(err error) bool { | ||
return errors.Is(err, ErrAlreadyExists) | ||
} | ||
|
||
// IsFailedPrecondition returns true if an operation could not proceed to the | ||
// lack of a particular condition | ||
func IsFailedPrecondition(err error) bool { | ||
return errors.Is(err, ErrFailedPrecondition) | ||
} | ||
|
||
// IsUnavailable returns true if the error is due to a resource being unavailable | ||
func IsUnavailable(err error) bool { | ||
return errors.Is(err, ErrUnavailable) | ||
} | ||
|
||
// IsNotImplemented returns true if the error is due to not being implemented | ||
func IsNotImplemented(err error) bool { | ||
return errors.Is(err, ErrNotImplemented) | ||
} | ||
|
||
// IsCanceled returns true if the error is due to `context.Canceled`. | ||
func IsCanceled(err error) bool { | ||
return errors.Is(err, context.Canceled) | ||
} | ||
|
||
// IsDeadlineExceeded returns true if the error is due to | ||
// `context.DeadlineExceeded`. | ||
func IsDeadlineExceeded(err error) bool { | ||
return errors.Is(err, context.DeadlineExceeded) | ||
} |
Oops, something went wrong.