mirror of https://github.com/k3d-io/k3d
parent
c5e5adb0e2
commit
c1263487a5
@ -0,0 +1,191 @@ |
||||
|
||||
Apache License |
||||
Version 2.0, January 2004 |
||||
https://www.apache.org/licenses/ |
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION |
||||
|
||||
1. Definitions. |
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction, |
||||
and distribution as defined by Sections 1 through 9 of this document. |
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by |
||||
the copyright owner that is granting the License. |
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all |
||||
other entities that control, are controlled by, or are under common |
||||
control with that entity. For the purposes of this definition, |
||||
"control" means (i) the power, direct or indirect, to cause the |
||||
direction or management of such entity, whether by contract or |
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the |
||||
outstanding shares, or (iii) beneficial ownership of such entity. |
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity |
||||
exercising permissions granted by this License. |
||||
|
||||
"Source" form shall mean the preferred form for making modifications, |
||||
including but not limited to software source code, documentation |
||||
source, and configuration files. |
||||
|
||||
"Object" form shall mean any form resulting from mechanical |
||||
transformation or translation of a Source form, including but |
||||
not limited to compiled object code, generated documentation, |
||||
and conversions to other media types. |
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or |
||||
Object form, made available under the License, as indicated by a |
||||
copyright notice that is included in or attached to the work |
||||
(an example is provided in the Appendix below). |
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object |
||||
form, that is based on (or derived from) the Work and for which the |
||||
editorial revisions, annotations, elaborations, or other modifications |
||||
represent, as a whole, an original work of authorship. For the purposes |
||||
of this License, Derivative Works shall not include works that remain |
||||
separable from, or merely link (or bind by name) to the interfaces of, |
||||
the Work and Derivative Works thereof. |
||||
|
||||
"Contribution" shall mean any work of authorship, including |
||||
the original version of the Work and any modifications or additions |
||||
to that Work or Derivative Works thereof, that is intentionally |
||||
submitted to Licensor for inclusion in the Work by the copyright owner |
||||
or by an individual or Legal Entity authorized to submit on behalf of |
||||
the copyright owner. For the purposes of this definition, "submitted" |
||||
means any form of electronic, verbal, or written communication sent |
||||
to the Licensor or its representatives, including but not limited to |
||||
communication on electronic mailing lists, source code control systems, |
||||
and issue tracking systems that are managed by, or on behalf of, the |
||||
Licensor for the purpose of discussing and improving the Work, but |
||||
excluding communication that is conspicuously marked or otherwise |
||||
designated in writing by the copyright owner as "Not a Contribution." |
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity |
||||
on behalf of whom a Contribution has been received by Licensor and |
||||
subsequently incorporated within the Work. |
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of |
||||
this License, each Contributor hereby grants to You a perpetual, |
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
||||
copyright license to reproduce, prepare Derivative Works of, |
||||
publicly display, publicly perform, sublicense, and distribute the |
||||
Work and such Derivative Works in Source or Object form. |
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of |
||||
this License, each Contributor hereby grants to You a perpetual, |
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable |
||||
(except as stated in this section) patent license to make, have made, |
||||
use, offer to sell, sell, import, and otherwise transfer the Work, |
||||
where such license applies only to those patent claims licensable |
||||
by such Contributor that are necessarily infringed by their |
||||
Contribution(s) alone or by combination of their Contribution(s) |
||||
with the Work to which such Contribution(s) was submitted. If You |
||||
institute patent litigation against any entity (including a |
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work |
||||
or a Contribution incorporated within the Work constitutes direct |
||||
or contributory patent infringement, then any patent licenses |
||||
granted to You under this License for that Work shall terminate |
||||
as of the date such litigation is filed. |
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the |
||||
Work or Derivative Works thereof in any medium, with or without |
||||
modifications, and in Source or Object form, provided that You |
||||
meet the following conditions: |
||||
|
||||
(a) You must give any other recipients of the Work or |
||||
Derivative Works a copy of this License; and |
||||
|
||||
(b) You must cause any modified files to carry prominent notices |
||||
stating that You changed the files; and |
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works |
||||
that You distribute, all copyright, patent, trademark, and |
||||
attribution notices from the Source form of the Work, |
||||
excluding those notices that do not pertain to any part of |
||||
the Derivative Works; and |
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its |
||||
distribution, then any Derivative Works that You distribute must |
||||
include a readable copy of the attribution notices contained |
||||
within such NOTICE file, excluding those notices that do not |
||||
pertain to any part of the Derivative Works, in at least one |
||||
of the following places: within a NOTICE text file distributed |
||||
as part of the Derivative Works; within the Source form or |
||||
documentation, if provided along with the Derivative Works; or, |
||||
within a display generated by the Derivative Works, if and |
||||
wherever such third-party notices normally appear. The contents |
||||
of the NOTICE file are for informational purposes only and |
||||
do not modify the License. You may add Your own attribution |
||||
notices within Derivative Works that You distribute, alongside |
||||
or as an addendum to the NOTICE text from the Work, provided |
||||
that such additional attribution notices cannot be construed |
||||
as modifying the License. |
||||
|
||||
You may add Your own copyright statement to Your modifications and |
||||
may provide additional or different license terms and conditions |
||||
for use, reproduction, or distribution of Your modifications, or |
||||
for any such Derivative Works as a whole, provided Your use, |
||||
reproduction, and distribution of the Work otherwise complies with |
||||
the conditions stated in this License. |
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, |
||||
any Contribution intentionally submitted for inclusion in the Work |
||||
by You to the Licensor shall be under the terms and conditions of |
||||
this License, without any additional terms or conditions. |
||||
Notwithstanding the above, nothing herein shall supersede or modify |
||||
the terms of any separate license agreement you may have executed |
||||
with Licensor regarding such Contributions. |
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade |
||||
names, trademarks, service marks, or product names of the Licensor, |
||||
except as required for reasonable and customary use in describing the |
||||
origin of the Work and reproducing the content of the NOTICE file. |
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or |
||||
agreed to in writing, Licensor provides the Work (and each |
||||
Contributor provides its Contributions) on an "AS IS" BASIS, |
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
||||
implied, including, without limitation, any warranties or conditions |
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A |
||||
PARTICULAR PURPOSE. You are solely responsible for determining the |
||||
appropriateness of using or redistributing the Work and assume any |
||||
risks associated with Your exercise of permissions under this License. |
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory, |
||||
whether in tort (including negligence), contract, or otherwise, |
||||
unless required by applicable law (such as deliberate and grossly |
||||
negligent acts) or agreed to in writing, shall any Contributor be |
||||
liable to You for damages, including any direct, indirect, special, |
||||
incidental, or consequential damages of any character arising as a |
||||
result of this License or out of the use or inability to use the |
||||
Work (including but not limited to damages for loss of goodwill, |
||||
work stoppage, computer failure or malfunction, or any and all |
||||
other commercial damages or losses), even if such Contributor |
||||
has been advised of the possibility of such damages. |
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing |
||||
the Work or Derivative Works thereof, You may choose to offer, |
||||
and charge a fee for, acceptance of support, warranty, indemnity, |
||||
or other liability obligations and/or rights consistent with this |
||||
License. However, in accepting such obligations, You may act only |
||||
on Your own behalf and on Your sole responsibility, not on behalf |
||||
of any other Contributor, and only if You agree to indemnify, |
||||
defend, and hold each Contributor harmless for any liability |
||||
incurred by, or claims asserted against, such Contributor by reason |
||||
of your accepting any such warranty or additional liability. |
||||
|
||||
END OF TERMS AND CONDITIONS |
||||
|
||||
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 |
||||
|
||||
https://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. |
@ -0,0 +1,16 @@ |
||||
Docker |
||||
Copyright 2012-2015 Docker, Inc. |
||||
|
||||
This product includes software developed at Docker, Inc. (https://www.docker.com). |
||||
|
||||
The following is courtesy of our legal counsel: |
||||
|
||||
|
||||
Use and transfer of Docker may be subject to certain restrictions by the |
||||
United States and other governments. |
||||
It is your responsibility to ensure that your use and/or transfer does not |
||||
violate applicable laws. |
||||
|
||||
For more information, please see https://www.bis.doc.gov |
||||
|
||||
See also https://www.apache.org/dev/crypto.html and/or seek legal counsel. |
@ -0,0 +1,78 @@ |
||||
/* |
||||
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 "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.Cause(err) == ErrInvalidArgument |
||||
} |
||||
|
||||
// IsNotFound returns true if the error is due to a missing object
|
||||
func IsNotFound(err error) bool { |
||||
return errors.Cause(err) == ErrNotFound |
||||
} |
||||
|
||||
// IsAlreadyExists returns true if the error is due to an already existing
|
||||
// metadata item
|
||||
func IsAlreadyExists(err error) bool { |
||||
return errors.Cause(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.Cause(err) == ErrFailedPrecondition |
||||
} |
||||
|
||||
// IsUnavailable returns true if the error is due to a resource being unavailable
|
||||
func IsUnavailable(err error) bool { |
||||
return errors.Cause(err) == ErrUnavailable |
||||
} |
||||
|
||||
// IsNotImplemented returns true if the error is due to not being implemented
|
||||
func IsNotImplemented(err error) bool { |
||||
return errors.Cause(err) == ErrNotImplemented |
||||
} |
@ -0,0 +1,138 @@ |
||||
/* |
||||
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 |
||||
|
||||
import ( |
||||
"strings" |
||||
|
||||
"github.com/pkg/errors" |
||||
"google.golang.org/grpc/codes" |
||||
"google.golang.org/grpc/status" |
||||
) |
||||
|
||||
// ToGRPC will attempt to map the backend containerd error into a grpc error,
|
||||
// using the original error message as a description.
|
||||
//
|
||||
// Further information may be extracted from certain errors depending on their
|
||||
// type.
|
||||
//
|
||||
// If the error is unmapped, the original error will be returned to be handled
|
||||
// by the regular grpc error handling stack.
|
||||
func ToGRPC(err error) error { |
||||
if err == nil { |
||||
return nil |
||||
} |
||||
|
||||
if isGRPCError(err) { |
||||
// error has already been mapped to grpc
|
||||
return err |
||||
} |
||||
|
||||
switch { |
||||
case IsInvalidArgument(err): |
||||
return status.Errorf(codes.InvalidArgument, err.Error()) |
||||
case IsNotFound(err): |
||||
return status.Errorf(codes.NotFound, err.Error()) |
||||
case IsAlreadyExists(err): |
||||
return status.Errorf(codes.AlreadyExists, err.Error()) |
||||
case IsFailedPrecondition(err): |
||||
return status.Errorf(codes.FailedPrecondition, err.Error()) |
||||
case IsUnavailable(err): |
||||
return status.Errorf(codes.Unavailable, err.Error()) |
||||
case IsNotImplemented(err): |
||||
return status.Errorf(codes.Unimplemented, err.Error()) |
||||
} |
||||
|
||||
return err |
||||
} |
||||
|
||||
// ToGRPCf maps the error to grpc error codes, assembling the formatting string
|
||||
// and combining it with the target error string.
|
||||
//
|
||||
// This is equivalent to errors.ToGRPC(errors.Wrapf(err, format, args...))
|
||||
func ToGRPCf(err error, format string, args ...interface{}) error { |
||||
return ToGRPC(errors.Wrapf(err, format, args...)) |
||||
} |
||||
|
||||
// FromGRPC returns the underlying error from a grpc service based on the grpc error code
|
||||
func FromGRPC(err error) error { |
||||
if err == nil { |
||||
return nil |
||||
} |
||||
|
||||
var cls error // divide these into error classes, becomes the cause
|
||||
|
||||
switch code(err) { |
||||
case codes.InvalidArgument: |
||||
cls = ErrInvalidArgument |
||||
case codes.AlreadyExists: |
||||
cls = ErrAlreadyExists |
||||
case codes.NotFound: |
||||
cls = ErrNotFound |
||||
case codes.Unavailable: |
||||
cls = ErrUnavailable |
||||
case codes.FailedPrecondition: |
||||
cls = ErrFailedPrecondition |
||||
case codes.Unimplemented: |
||||
cls = ErrNotImplemented |
||||
default: |
||||
cls = ErrUnknown |
||||
} |
||||
|
||||
msg := rebaseMessage(cls, err) |
||||
if msg != "" { |
||||
err = errors.Wrapf(cls, msg) |
||||
} else { |
||||
err = errors.WithStack(cls) |
||||
} |
||||
|
||||
return err |
||||
} |
||||
|
||||
// rebaseMessage removes the repeats for an error at the end of an error
|
||||
// string. This will happen when taking an error over grpc then remapping it.
|
||||
//
|
||||
// Effectively, we just remove the string of cls from the end of err if it
|
||||
// appears there.
|
||||
func rebaseMessage(cls error, err error) string { |
||||
desc := errDesc(err) |
||||
clss := cls.Error() |
||||
if desc == clss { |
||||
return "" |
||||
} |
||||
|
||||
return strings.TrimSuffix(desc, ": "+clss) |
||||
} |
||||
|
||||
func isGRPCError(err error) bool { |
||||
_, ok := status.FromError(err) |
||||
return ok |
||||
} |
||||
|
||||
func code(err error) codes.Code { |
||||
if s, ok := status.FromError(err); ok { |
||||
return s.Code() |
||||
} |
||||
return codes.Unknown |
||||
} |
||||
|
||||
func errDesc(err error) string { |
||||
if s, ok := status.FromError(err); ok { |
||||
return s.Message() |
||||
} |
||||
return err.Error() |
||||
} |
@ -0,0 +1,267 @@ |
||||
package errcode |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"fmt" |
||||
"strings" |
||||
) |
||||
|
||||
// ErrorCoder is the base interface for ErrorCode and Error allowing
|
||||
// users of each to just call ErrorCode to get the real ID of each
|
||||
type ErrorCoder interface { |
||||
ErrorCode() ErrorCode |
||||
} |
||||
|
||||
// ErrorCode represents the error type. The errors are serialized via strings
|
||||
// and the integer format may change and should *never* be exported.
|
||||
type ErrorCode int |
||||
|
||||
var _ error = ErrorCode(0) |
||||
|
||||
// ErrorCode just returns itself
|
||||
func (ec ErrorCode) ErrorCode() ErrorCode { |
||||
return ec |
||||
} |
||||
|
||||
// Error returns the ID/Value
|
||||
func (ec ErrorCode) Error() string { |
||||
// NOTE(stevvooe): Cannot use message here since it may have unpopulated args.
|
||||
return strings.ToLower(strings.Replace(ec.String(), "_", " ", -1)) |
||||
} |
||||
|
||||
// Descriptor returns the descriptor for the error code.
|
||||
func (ec ErrorCode) Descriptor() ErrorDescriptor { |
||||
d, ok := errorCodeToDescriptors[ec] |
||||
|
||||
if !ok { |
||||
return ErrorCodeUnknown.Descriptor() |
||||
} |
||||
|
||||
return d |
||||
} |
||||
|
||||
// String returns the canonical identifier for this error code.
|
||||
func (ec ErrorCode) String() string { |
||||
return ec.Descriptor().Value |
||||
} |
||||
|
||||
// Message returned the human-readable error message for this error code.
|
||||
func (ec ErrorCode) Message() string { |
||||
return ec.Descriptor().Message |
||||
} |
||||
|
||||
// MarshalText encodes the receiver into UTF-8-encoded text and returns the
|
||||
// result.
|
||||
func (ec ErrorCode) MarshalText() (text []byte, err error) { |
||||
return []byte(ec.String()), nil |
||||
} |
||||
|
||||
// UnmarshalText decodes the form generated by MarshalText.
|
||||
func (ec *ErrorCode) UnmarshalText(text []byte) error { |
||||
desc, ok := idToDescriptors[string(text)] |
||||
|
||||
if !ok { |
||||
desc = ErrorCodeUnknown.Descriptor() |
||||
} |
||||
|
||||
*ec = desc.Code |
||||
|
||||
return nil |
||||
} |
||||
|
||||
// WithMessage creates a new Error struct based on the passed-in info and
|
||||
// overrides the Message property.
|
||||
func (ec ErrorCode) WithMessage(message string) Error { |
||||
return Error{ |
||||
Code: ec, |
||||
Message: message, |
||||
} |
||||
} |
||||
|
||||
// WithDetail creates a new Error struct based on the passed-in info and
|
||||
// set the Detail property appropriately
|
||||
func (ec ErrorCode) WithDetail(detail interface{}) Error { |
||||
return Error{ |
||||
Code: ec, |
||||
Message: ec.Message(), |
||||
}.WithDetail(detail) |
||||
} |
||||
|
||||
// WithArgs creates a new Error struct and sets the Args slice
|
||||
func (ec ErrorCode) WithArgs(args ...interface{}) Error { |
||||
return Error{ |
||||
Code: ec, |
||||
Message: ec.Message(), |
||||
}.WithArgs(args...) |
||||
} |
||||
|
||||
// Error provides a wrapper around ErrorCode with extra Details provided.
|
||||
type Error struct { |
||||
Code ErrorCode `json:"code"` |
||||
Message string `json:"message"` |
||||
Detail interface{} `json:"detail,omitempty"` |
||||
|
||||
// TODO(duglin): See if we need an "args" property so we can do the
|
||||
// variable substitution right before showing the message to the user
|
||||
} |
||||
|
||||
var _ error = Error{} |
||||
|
||||
// ErrorCode returns the ID/Value of this Error
|
||||
func (e Error) ErrorCode() ErrorCode { |
||||
return e.Code |
||||
} |
||||
|
||||
// Error returns a human readable representation of the error.
|
||||
func (e Error) Error() string { |
||||
return fmt.Sprintf("%s: %s", e.Code.Error(), e.Message) |
||||
} |
||||
|
||||
// WithDetail will return a new Error, based on the current one, but with
|
||||
// some Detail info added
|
||||
func (e Error) WithDetail(detail interface{}) Error { |
||||
return Error{ |
||||
Code: e.Code, |
||||
Message: e.Message, |
||||
Detail: detail, |
||||
} |
||||
} |
||||
|
||||
// WithArgs uses the passed-in list of interface{} as the substitution
|
||||
// variables in the Error's Message string, but returns a new Error
|
||||
func (e Error) WithArgs(args ...interface{}) Error { |
||||
return Error{ |
||||
Code: e.Code, |
||||
Message: fmt.Sprintf(e.Code.Message(), args...), |
||||
Detail: e.Detail, |
||||
} |
||||
} |
||||
|
||||
// ErrorDescriptor provides relevant information about a given error code.
|
||||
type ErrorDescriptor struct { |
||||
// Code is the error code that this descriptor describes.
|
||||
Code ErrorCode |
||||
|
||||
// Value provides a unique, string key, often captilized with
|
||||
// underscores, to identify the error code. This value is used as the
|
||||
// keyed value when serializing api errors.
|
||||
Value string |
||||
|
||||
// Message is a short, human readable decription of the error condition
|
||||
// included in API responses.
|
||||
Message string |
||||
|
||||
// Description provides a complete account of the errors purpose, suitable
|
||||
// for use in documentation.
|
||||
Description string |
||||
|
||||
// HTTPStatusCode provides the http status code that is associated with
|
||||
// this error condition.
|
||||
HTTPStatusCode int |
||||
} |
||||
|
||||
// ParseErrorCode returns the value by the string error code.
|
||||
// `ErrorCodeUnknown` will be returned if the error is not known.
|
||||
func ParseErrorCode(value string) ErrorCode { |
||||
ed, ok := idToDescriptors[value] |
||||
if ok { |
||||
return ed.Code |
||||
} |
||||
|
||||
return ErrorCodeUnknown |
||||
} |
||||
|
||||
// Errors provides the envelope for multiple errors and a few sugar methods
|
||||
// for use within the application.
|
||||
type Errors []error |
||||
|
||||
var _ error = Errors{} |
||||
|
||||
func (errs Errors) Error() string { |
||||
switch len(errs) { |
||||
case 0: |
||||
return "<nil>" |
||||
case 1: |
||||
return errs[0].Error() |
||||
default: |
||||
msg := "errors:\n" |
||||
for _, err := range errs { |
||||
msg += err.Error() + "\n" |
||||
} |
||||
return msg |
||||
} |
||||
} |
||||
|
||||
// Len returns the current number of errors.
|
||||
func (errs Errors) Len() int { |
||||
return len(errs) |
||||
} |
||||
|
||||
// MarshalJSON converts slice of error, ErrorCode or Error into a
|
||||
// slice of Error - then serializes
|
||||
func (errs Errors) MarshalJSON() ([]byte, error) { |
||||
var tmpErrs struct { |
||||
Errors []Error `json:"errors,omitempty"` |
||||
} |
||||
|
||||
for _, daErr := range errs { |
||||
var err Error |
||||
|
||||
switch daErr.(type) { |
||||
case ErrorCode: |
||||
err = daErr.(ErrorCode).WithDetail(nil) |
||||
case Error: |
||||
err = daErr.(Error) |
||||
default: |
||||
err = ErrorCodeUnknown.WithDetail(daErr) |
||||
|
||||
} |
||||
|
||||
// If the Error struct was setup and they forgot to set the
|
||||
// Message field (meaning its "") then grab it from the ErrCode
|
||||
msg := err.Message |
||||
if msg == "" { |
||||
msg = err.Code.Message() |
||||
} |
||||
|
||||
tmpErrs.Errors = append(tmpErrs.Errors, Error{ |
||||
Code: err.Code, |
||||
Message: msg, |
||||
Detail: err.Detail, |
||||
}) |
||||
} |
||||
|
||||
return json.Marshal(tmpErrs) |
||||
} |
||||
|
||||
// UnmarshalJSON deserializes []Error and then converts it into slice of
|
||||
// Error or ErrorCode
|
||||
func (errs *Errors) UnmarshalJSON(data []byte) error { |
||||
var tmpErrs struct { |
||||
Errors []Error |
||||
} |
||||
|
||||
if err := json.Unmarshal(data, &tmpErrs); err != nil { |
||||
return err |
||||
} |
||||
|
||||
var newErrs Errors |
||||
for _, daErr := range tmpErrs.Errors { |
||||
// If Message is empty or exactly matches the Code's message string
|
||||
// then just use the Code, no need for a full Error struct
|
||||
if daErr.Detail == nil && (daErr.Message == "" || daErr.Message == daErr.Code.Message()) { |
||||
// Error's w/o details get converted to ErrorCode
|
||||
newErrs = append(newErrs, daErr.Code) |
||||
} else { |
||||
// Error's w/ details are untouched
|
||||
newErrs = append(newErrs, Error{ |
||||
Code: daErr.Code, |
||||
Message: daErr.Message, |
||||
Detail: daErr.Detail, |
||||
}) |
||||
} |
||||
} |
||||
|
||||
*errs = newErrs |
||||
return nil |
||||
} |
@ -0,0 +1,40 @@ |
||||
package errcode |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"net/http" |
||||
) |
||||
|
||||
// ServeJSON attempts to serve the errcode in a JSON envelope. It marshals err
|
||||
// and sets the content-type header to 'application/json'. It will handle
|
||||
// ErrorCoder and Errors, and if necessary will create an envelope.
|
||||
func ServeJSON(w http.ResponseWriter, err error) error { |
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8") |
||||
var sc int |
||||
|
||||
switch errs := err.(type) { |
||||
case Errors: |
||||
if len(errs) < 1 { |
||||
break |
||||
} |
||||
|
||||
if err, ok := errs[0].(ErrorCoder); ok { |
||||
sc = err.ErrorCode().Descriptor().HTTPStatusCode |
||||
} |
||||
case ErrorCoder: |
||||
sc = errs.ErrorCode().Descriptor().HTTPStatusCode |
||||
err = Errors{err} // create an envelope.
|
||||
default: |
||||
// We just have an unhandled error type, so just place in an envelope
|
||||
// and move along.
|
||||
err = Errors{err} |
||||
} |
||||
|
||||
if sc == 0 { |
||||
sc = http.StatusInternalServerError |
||||
} |
||||
|
||||
w.WriteHeader(sc) |
||||
|
||||
return json.NewEncoder(w).Encode(err) |
||||
} |
@ -0,0 +1,138 @@ |
||||
package errcode |
||||
|
||||
import ( |
||||
"fmt" |
||||
"net/http" |
||||
"sort" |
||||
"sync" |
||||
) |
||||
|
||||
var ( |
||||
errorCodeToDescriptors = map[ErrorCode]ErrorDescriptor{} |
||||
idToDescriptors = map[string]ErrorDescriptor{} |
||||
groupToDescriptors = map[string][]ErrorDescriptor{} |
||||
) |
||||
|
||||
var ( |
||||
// ErrorCodeUnknown is a generic error that can be used as a last
|
||||
// resort if there is no situation-specific error message that can be used
|
||||
ErrorCodeUnknown = Register("errcode", ErrorDescriptor{ |
||||
Value: "UNKNOWN", |
||||
Message: "unknown error", |
||||
Description: `Generic error returned when the error does not have an |
||||
API classification.`, |
||||
HTTPStatusCode: http.StatusInternalServerError, |
||||
}) |
||||
|
||||
// ErrorCodeUnsupported is returned when an operation is not supported.
|
||||
ErrorCodeUnsupported = Register("errcode", ErrorDescriptor{ |
||||
Value: "UNSUPPORTED", |
||||
Message: "The operation is unsupported.", |
||||
Description: `The operation was unsupported due to a missing |
||||
implementation or invalid set of parameters.`, |
||||
HTTPStatusCode: http.StatusMethodNotAllowed, |
||||
}) |
||||
|
||||
// ErrorCodeUnauthorized is returned if a request requires
|
||||
// authentication.
|
||||
ErrorCodeUnauthorized = Register("errcode", ErrorDescriptor{ |
||||
Value: "UNAUTHORIZED", |
||||
Message: "authentication required", |
||||
Description: `The access controller was unable to authenticate |
||||
the client. Often this will be accompanied by a |
||||
Www-Authenticate HTTP response header indicating how to |
||||
authenticate.`, |
||||
HTTPStatusCode: http.StatusUnauthorized, |
||||
}) |
||||
|
||||
// ErrorCodeDenied is returned if a client does not have sufficient
|
||||
// permission to perform an action.
|
||||
ErrorCodeDenied = Register("errcode", ErrorDescriptor{ |
||||
Value: "DENIED", |
||||
Message: "requested access to the resource is denied", |
||||
Description: `The access controller denied access for the |
||||
operation on a resource.`, |
||||
HTTPStatusCode: http.StatusForbidden, |
||||
}) |
||||
|
||||
// ErrorCodeUnavailable provides a common error to report unavailability
|
||||
// of a service or endpoint.
|
||||
ErrorCodeUnavailable = Register("errcode", ErrorDescriptor{ |
||||
Value: "UNAVAILABLE", |
||||
Message: "service unavailable", |
||||
Description: "Returned when a service is not available", |
||||
HTTPStatusCode: http.StatusServiceUnavailable, |
||||
}) |
||||
|
||||
// ErrorCodeTooManyRequests is returned if a client attempts too many
|
||||
// times to contact a service endpoint.
|
||||
ErrorCodeTooManyRequests = Register("errcode", ErrorDescriptor{ |
||||
Value: "TOOMANYREQUESTS", |
||||
Message: "too many requests", |
||||
Description: `Returned when a client attempts to contact a |
||||
service too many times`, |
||||
HTTPStatusCode: http.StatusTooManyRequests, |
||||
}) |
||||
) |
||||
|
||||
var nextCode = 1000 |
||||
var registerLock sync.Mutex |
||||
|
||||
// Register will make the passed-in error known to the environment and
|
||||
// return a new ErrorCode
|
||||
func Register(group string, descriptor ErrorDescriptor) ErrorCode { |
||||
registerLock.Lock() |
||||
defer registerLock.Unlock() |
||||
|
||||
descriptor.Code = ErrorCode(nextCode) |
||||
|
||||
if _, ok := idToDescriptors[descriptor.Value]; ok { |
||||
panic(fmt.Sprintf("ErrorValue %q is already registered", descriptor.Value)) |
||||
} |
||||
if _, ok := errorCodeToDescriptors[descriptor.Code]; ok { |
||||
panic(fmt.Sprintf("ErrorCode %v is already registered", descriptor.Code)) |
||||
} |
||||
|
||||
groupToDescriptors[group] = append(groupToDescriptors[group], descriptor) |
||||
errorCodeToDescriptors[descriptor.Code] = descriptor |
||||
idToDescriptors[descriptor.Value] = descriptor |
||||
|
||||
nextCode++ |
||||
return descriptor.Code |
||||
} |
||||
|
||||
type byValue []ErrorDescriptor |
||||
|
||||
func (a byValue) Len() int { return len(a) } |
||||
func (a byValue) Swap(i, j int) { a[i], a[j] = a[j], a[i] } |
||||
func (a byValue) Less(i, j int) bool { return a[i].Value < a[j].Value } |
||||
|
||||
// GetGroupNames returns the list of Error group names that are registered
|
||||
func GetGroupNames() []string { |
||||
keys := []string{} |
||||
|
||||
for k := range groupToDescriptors { |
||||
keys = append(keys, k) |
||||
} |
||||
sort.Strings(keys) |
||||
return keys |
||||
} |
||||
|
||||
// GetErrorCodeGroup returns the named group of error descriptors
|
||||
func GetErrorCodeGroup(name string) []ErrorDescriptor { |
||||
desc := groupToDescriptors[name] |
||||
sort.Sort(byValue(desc)) |
||||
return desc |
||||
} |
||||
|
||||
// GetErrorAllDescriptors returns a slice of all ErrorDescriptors that are
|
||||
// registered, irrespective of what group they're in
|
||||
func GetErrorAllDescriptors() []ErrorDescriptor { |
||||
result := []ErrorDescriptor{} |
||||
|
||||
for _, group := range GetGroupNames() { |
||||
result = append(result, GetErrorCodeGroup(group)...) |
||||
} |
||||
sort.Sort(byValue(result)) |
||||
return result |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,42 @@ |
||||
# Working on the Engine API |
||||
|
||||
The Engine API is an HTTP API used by the command-line client to communicate with the daemon. It can also be used by third-party software to control the daemon. |
||||
|
||||
It consists of various components in this repository: |
||||
|
||||
- `api/swagger.yaml` A Swagger definition of the API. |
||||
- `api/types/` Types shared by both the client and server, representing various objects, options, responses, etc. Most are written manually, but some are automatically generated from the Swagger definition. See [#27919](https://github.com/docker/docker/issues/27919) for progress on this. |
||||
- `cli/` The command-line client. |
||||
- `client/` The Go client used by the command-line client. It can also be used by third-party Go programs. |
||||
- `daemon/` The daemon, which serves the API. |
||||
|
||||
## Swagger definition |
||||
|
||||
The API is defined by the [Swagger](http://swagger.io/specification/) definition in `api/swagger.yaml`. This definition can be used to: |
||||
|
||||
1. Automatically generate documentation. |
||||
2. Automatically generate the Go server and client. (A work-in-progress.) |
||||
3. Provide a machine readable version of the API for introspecting what it can do, automatically generating clients for other languages, etc. |
||||
|
||||
## Updating the API documentation |
||||
|
||||
The API documentation is generated entirely from `api/swagger.yaml`. If you make updates to the API, edit this file to represent the change in the documentation. |
||||
|
||||
The file is split into two main sections: |
||||
|
||||
- `definitions`, which defines re-usable objects used in requests and responses |
||||
- `paths`, which defines the API endpoints (and some inline objects which don't need to be reusable) |
||||
|
||||
To make an edit, first look for the endpoint you want to edit under `paths`, then make the required edits. Endpoints may reference reusable objects with `$ref`, which can be found in the `definitions` section. |
||||
|
||||
There is hopefully enough example material in the file for you to copy a similar pattern from elsewhere in the file (e.g. adding new fields or endpoints), but for the full reference, see the [Swagger specification](https://github.com/docker/docker/issues/27919). |
||||
|
||||
`swagger.yaml` is validated by `hack/validate/swagger` to ensure it is a valid Swagger definition. This is useful when making edits to ensure you are doing the right thing. |
||||
|
||||
## Viewing the API documentation |
||||
|
||||
When you make edits to `swagger.yaml`, you may want to check the generated API documentation to ensure it renders correctly. |
||||
|
||||
Run `make swagger-docs` and a preview will be running at `http://localhost`. Some of the styling may be incorrect, but you'll be able to ensure that it is generating the correct documentation. |
||||
|
||||
The production documentation is generated by vendoring `swagger.yaml` into [docker/docker.github.io](https://github.com/docker/docker.github.io). |
@ -0,0 +1,11 @@ |
||||
package api // import "github.com/docker/docker/api"
|
||||
|
||||
// Common constants for daemon and client.
|
||||
const ( |
||||
// DefaultVersion of Current REST API
|
||||
DefaultVersion = "1.41" |
||||
|
||||
// NoBaseImageSpecifier is the symbol used by the FROM
|
||||
// command to specify that no base image is to be used.
|
||||
NoBaseImageSpecifier = "scratch" |
||||
) |
@ -0,0 +1,6 @@ |
||||
// +build !windows
|
||||
|
||||
package api // import "github.com/docker/docker/api"
|
||||
|
||||
// MinVersion represents Minimum REST API version supported
|
||||
const MinVersion = "1.12" |
@ -0,0 +1,8 @@ |
||||
package api // import "github.com/docker/docker/api"
|
||||
|
||||
// MinVersion represents Minimum REST API version supported
|
||||
// Technically the first daemon API version released on Windows is v1.25 in
|
||||
// engine version 1.13. However, some clients are explicitly using downlevel
|
||||
// APIs (e.g. docker-compose v2.1 file format) and that is just too restrictive.
|
||||
// Hence also allowing 1.24 on Windows.
|
||||
const MinVersion string = "1.24" |
@ -0,0 +1,12 @@ |
||||
|
||||
layout: |
||||
models: |
||||
- name: definition |
||||
source: asset:model |
||||
target: "{{ joinFilePath .Target .ModelPackage }}" |
||||
file_name: "{{ (snakize (pascalize .Name)) }}.go" |
||||
operations: |
||||
- name: handler |
||||
source: asset:serverOperation |
||||
target: "{{ joinFilePath .Target .APIPackage .Package }}" |
||||
file_name: "{{ (snakize (pascalize .Name)) }}.go" |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,21 @@ |
||||
package container // import "github.com/docker/docker/api/types/container"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// DO NOT EDIT THIS FILE
|
||||
// This file was generated by `swagger generate operation`
|
||||
//
|
||||
// See hack/generate-swagger-api.sh
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// ContainerChangeResponseItem change item in response to ContainerChanges operation
|
||||
// swagger:model ContainerChangeResponseItem
|
||||
type ContainerChangeResponseItem struct { |
||||
|
||||
// Kind of change
|
||||
// Required: true
|
||||
Kind uint8 `json:"Kind"` |
||||
|
||||
// Path to file that has changed
|
||||
// Required: true
|
||||
Path string `json:"Path"` |
||||
} |
@ -0,0 +1,21 @@ |
||||
package container // import "github.com/docker/docker/api/types/container"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// DO NOT EDIT THIS FILE
|
||||
// This file was generated by `swagger generate operation`
|
||||
//
|
||||
// See hack/generate-swagger-api.sh
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// ContainerTopOKBody OK response to ContainerTop operation
|
||||
// swagger:model ContainerTopOKBody
|
||||
type ContainerTopOKBody struct { |
||||
|
||||
// Each process running in the container, where each is process is an array of values corresponding to the titles
|
||||
// Required: true
|
||||
Processes [][]string `json:"Processes"` |
||||
|
||||
// The ps column titles
|
||||
// Required: true
|
||||
Titles []string `json:"Titles"` |
||||
} |
@ -0,0 +1,22 @@ |
||||
package container // import "github.com/docker/docker/api/types/container"
|
||||
|
||||
// WaitCondition is a type used to specify a container state for which
|
||||
// to wait.
|
||||
type WaitCondition string |
||||
|
||||
// Possible WaitCondition Values.
|
||||
//
|
||||
// WaitConditionNotRunning (default) is used to wait for any of the non-running
|
||||
// states: "created", "exited", "dead", "removing", or "removed".
|
||||
//
|
||||
// WaitConditionNextExit is used to wait for the next time the state changes
|
||||
// to a non-running state. If the state is currently "created" or "exited",
|
||||
// this would cause Wait() to block until either the container runs and exits
|
||||
// or is removed.
|
||||
//
|
||||
// WaitConditionRemoved is used to wait for the container to be removed.
|
||||
const ( |
||||
WaitConditionNotRunning WaitCondition = "not-running" |
||||
WaitConditionNextExit WaitCondition = "next-exit" |
||||
WaitConditionRemoved WaitCondition = "removed" |
||||
) |
@ -0,0 +1,6 @@ |
||||
package types |
||||
|
||||
// Error returns the error message
|
||||
func (e ErrorResponse) Error() string { |
||||
return e.Message |
||||
} |
@ -0,0 +1,17 @@ |
||||
package types |
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// GraphDriverData Information about a container's graph driver.
|
||||
// swagger:model GraphDriverData
|
||||
type GraphDriverData struct { |
||||
|
||||
// data
|
||||
// Required: true
|
||||
Data map[string]string `json:"Data"` |
||||
|
||||
// name
|
||||
// Required: true
|
||||
Name string `json:"Name"` |
||||
} |
@ -0,0 +1,37 @@ |
||||
package image // import "github.com/docker/docker/api/types/image"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// DO NOT EDIT THIS FILE
|
||||
// This file was generated by `swagger generate operation`
|
||||
//
|
||||
// See hack/generate-swagger-api.sh
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// HistoryResponseItem individual image layer information in response to ImageHistory operation
|
||||
// swagger:model HistoryResponseItem
|
||||
type HistoryResponseItem struct { |
||||
|
||||
// comment
|
||||
// Required: true
|
||||
Comment string `json:"Comment"` |
||||
|
||||
// created
|
||||
// Required: true
|
||||
Created int64 `json:"Created"` |
||||
|
||||
// created by
|
||||
// Required: true
|
||||
CreatedBy string `json:"CreatedBy"` |
||||
|
||||
// Id
|
||||
// Required: true
|
||||
ID string `json:"Id"` |
||||
|
||||
// size
|
||||
// Required: true
|
||||
Size int64 `json:"Size"` |
||||
|
||||
// tags
|
||||
// Required: true
|
||||
Tags []string `json:"Tags"` |
||||
} |
@ -0,0 +1,15 @@ |
||||
package types |
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
// ImageDeleteResponseItem image delete response item
|
||||
// swagger:model ImageDeleteResponseItem
|
||||
type ImageDeleteResponseItem struct { |
||||
|
||||
// The image ID of an image that was deleted
|
||||
Deleted string `json:"Deleted,omitempty"` |
||||
|
||||
// The image ID of an image that was untagged
|
||||
Untagged string `json:"Untagged,omitempty"` |
||||
} |
@ -1,34 +0,0 @@ |
||||
package reference |
||||
|
||||
import ( |
||||
distreference "github.com/docker/distribution/reference" |
||||
) |
||||
|
||||
// Parse parses the given references and returns the repository and
|
||||
// tag (if present) from it. If there is an error during parsing, it will
|
||||
// return an error.
|
||||
func Parse(ref string) (string, string, error) { |
||||
distributionRef, err := distreference.ParseNamed(ref) |
||||
if err != nil { |
||||
return "", "", err |
||||
} |
||||
|
||||
tag := GetTagFromNamedRef(distributionRef) |
||||
return distributionRef.Name(), tag, nil |
||||
} |
||||
|
||||
// GetTagFromNamedRef returns a tag from the specified reference.
|
||||
// This function is necessary as long as the docker "server" api makes the distinction between repository
|
||||
// and tags.
|
||||
func GetTagFromNamedRef(ref distreference.Named) string { |
||||
var tag string |
||||
switch x := ref.(type) { |
||||
case distreference.Digested: |
||||
tag = x.Digest().String() |
||||
case distreference.NamedTagged: |
||||
tag = x.Tag() |
||||
default: |
||||
tag = "latest" |
||||
} |
||||
return tag |
||||
} |
@ -0,0 +1,40 @@ |
||||
package swarm // import "github.com/docker/docker/api/types/swarm"
|
||||
|
||||
import "os" |
||||
|
||||
// Config represents a config.
|
||||
type Config struct { |
||||
ID string |
||||
Meta |
||||
Spec ConfigSpec |
||||
} |
||||
|
||||
// ConfigSpec represents a config specification from a config in swarm
|
||||
type ConfigSpec struct { |
||||
Annotations |
||||
Data []byte `json:",omitempty"` |
||||
|
||||
// Templating controls whether and how to evaluate the config payload as
|
||||
// a template. If it is not set, no templating is used.
|
||||
Templating *Driver `json:",omitempty"` |
||||
} |
||||
|
||||
// ConfigReferenceFileTarget is a file target in a config reference
|
||||
type ConfigReferenceFileTarget struct { |
||||
Name string |
||||
UID string |
||||
GID string |
||||
Mode os.FileMode |
||||
} |
||||
|
||||
// ConfigReferenceRuntimeTarget is a target for a config specifying that it
|
||||
// isn't mounted into the container but instead has some other purpose.
|
||||
type ConfigReferenceRuntimeTarget struct{} |
||||
|
||||
// ConfigReference is a reference to a config in swarm
|
||||
type ConfigReference struct { |
||||
File *ConfigReferenceFileTarget `json:",omitempty"` |
||||
Runtime *ConfigReferenceRuntimeTarget `json:",omitempty"` |
||||
ConfigID string |
||||
ConfigName string |
||||
} |
@ -0,0 +1,27 @@ |
||||
package swarm // import "github.com/docker/docker/api/types/swarm"
|
||||
|
||||
// RuntimeType is the type of runtime used for the TaskSpec
|
||||
type RuntimeType string |
||||
|
||||
// RuntimeURL is the proto type url
|
||||
type RuntimeURL string |
||||
|
||||
const ( |
||||
// RuntimeContainer is the container based runtime
|
||||
RuntimeContainer RuntimeType = "container" |
||||
// RuntimePlugin is the plugin based runtime
|
||||
RuntimePlugin RuntimeType = "plugin" |
||||
// RuntimeNetworkAttachment is the network attachment runtime
|
||||
RuntimeNetworkAttachment RuntimeType = "attachment" |
||||
|
||||
// RuntimeURLContainer is the proto url for the container type
|
||||
RuntimeURLContainer RuntimeURL = "types.docker.com/RuntimeContainer" |
||||
// RuntimeURLPlugin is the proto url for the plugin type
|
||||
RuntimeURLPlugin RuntimeURL = "types.docker.com/RuntimePlugin" |
||||
) |
||||
|
||||
// NetworkAttachmentSpec represents the runtime spec type for network
|
||||
// attachment tasks
|
||||
type NetworkAttachmentSpec struct { |
||||
ContainerID string |
||||
} |
@ -0,0 +1,3 @@ |
||||
//go:generate protoc -I . --gogofast_out=import_path=github.com/docker/docker/api/types/swarm/runtime:. plugin.proto
|
||||
|
||||
package runtime // import "github.com/docker/docker/api/types/swarm/runtime"
|
@ -0,0 +1,754 @@ |
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: plugin.proto
|
||||
|
||||
/* |
||||
Package runtime is a generated protocol buffer package. |
||||
|
||||
It is generated from these files: |
||||
plugin.proto |
||||
|
||||
It has these top-level messages: |
||||
PluginSpec |
||||
PluginPrivilege |
||||
*/ |
||||
package runtime |
||||
|
||||
import proto "github.com/gogo/protobuf/proto" |
||||
import fmt "fmt" |
||||
import math "math" |
||||
|
||||
import io "io" |
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal |
||||
var _ = fmt.Errorf |
||||
var _ = math.Inf |
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
// PluginSpec defines the base payload which clients can specify for creating
|
||||
// a service with the plugin runtime.
|
||||
type PluginSpec struct { |
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` |
||||
Remote string `protobuf:"bytes,2,opt,name=remote,proto3" json:"remote,omitempty"` |
||||
Privileges []*PluginPrivilege `protobuf:"bytes,3,rep,name=privileges" json:"privileges,omitempty"` |
||||
Disabled bool `protobuf:"varint,4,opt,name=disabled,proto3" json:"disabled,omitempty"` |
||||
Env []string `protobuf:"bytes,5,rep,name=env" json:"env,omitempty"` |
||||
} |
||||
|
||||
func (m *PluginSpec) Reset() { *m = PluginSpec{} } |
||||
func (m *PluginSpec) String() string { return proto.CompactTextString(m) } |
||||
func (*PluginSpec) ProtoMessage() {} |
||||
func (*PluginSpec) Descriptor() ([]byte, []int) { return fileDescriptorPlugin, []int{0} } |
||||
|
||||
func (m *PluginSpec) GetName() string { |
||||
if m != nil { |
||||
return m.Name |
||||
} |
||||
return "" |
||||
} |
||||
|
||||
func (m *PluginSpec) GetRemote() string { |
||||
if m != nil { |
||||
return m.Remote |
||||
} |
||||
return "" |
||||
} |
||||
|
||||
func (m *PluginSpec) GetPrivileges() []*PluginPrivilege { |
||||
if m != nil { |
||||
return m.Privileges |
||||
} |
||||
return nil |
||||
} |
||||
|
||||
func (m *PluginSpec) GetDisabled() bool { |
||||
if m != nil { |
||||
return m.Disabled |
||||
} |
||||
return false |
||||
} |
||||
|
||||
func (m *PluginSpec) GetEnv() []string { |
||||
if m != nil { |
||||
return m.Env |
||||
} |
||||
return nil |
||||
} |
||||
|
||||
// PluginPrivilege describes a permission the user has to accept
|
||||
// upon installing a plugin.
|
||||
type PluginPrivilege struct { |
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` |
||||
Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` |
||||
Value []string `protobuf:"bytes,3,rep,name=value" json:"value,omitempty"` |
||||
} |
||||
|
||||
func (m *PluginPrivilege) Reset() { *m = PluginPrivilege{} } |
||||
func (m *PluginPrivilege) String() string { return proto.CompactTextString(m) } |
||||
func (*PluginPrivilege) ProtoMessage() {} |
||||
func (*PluginPrivilege) Descriptor() ([]byte, []int) { return fileDescriptorPlugin, []int{1} } |
||||
|
||||
func (m *PluginPrivilege) GetName() string { |
||||
if m != nil { |
||||
return m.Name |
||||
} |
||||
return "" |
||||
} |
||||
|
||||
func (m *PluginPrivilege) GetDescription() string { |
||||
if m != nil { |
||||
return m.Description |
||||
} |
||||
return "" |
||||
} |
||||
|
||||
func (m *PluginPrivilege) GetValue() []string { |
||||
if m != nil { |
||||
return m.Value |
||||
} |
||||
return nil |
||||
} |
||||
|
||||
func init() { |
||||
proto.RegisterType((*PluginSpec)(nil), "PluginSpec") |
||||
proto.RegisterType((*PluginPrivilege)(nil), "PluginPrivilege") |
||||
} |
||||
func (m *PluginSpec) Marshal() (dAtA []byte, err error) { |
||||
size := m.Size() |
||||
dAtA = make([]byte, size) |
||||
n, err := m.MarshalTo(dAtA) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return dAtA[:n], nil |
||||
} |
||||
|
||||
func (m *PluginSpec) MarshalTo(dAtA []byte) (int, error) { |
||||
var i int |
||||
_ = i |
||||
var l int |
||||
_ = l |
||||
if len(m.Name) > 0 { |
||||
dAtA[i] = 0xa |
||||
i++ |
||||
i = encodeVarintPlugin(dAtA, i, uint64(len(m.Name))) |
||||
i += copy(dAtA[i:], m.Name) |
||||
} |
||||
if len(m.Remote) > 0 { |
||||
dAtA[i] = 0x12 |
||||
i++ |
||||
i = encodeVarintPlugin(dAtA, i, uint64(len(m.Remote))) |
||||
i += copy(dAtA[i:], m.Remote) |
||||
} |
||||
if len(m.Privileges) > 0 { |
||||
for _, msg := range m.Privileges { |
||||
dAtA[i] = 0x1a |
||||
i++ |
||||
i = encodeVarintPlugin(dAtA, i, uint64(msg.Size())) |
||||
n, err := msg.MarshalTo(dAtA[i:]) |
||||
if err != nil { |
||||
return 0, err |
||||
} |
||||
i += n |
||||
} |
||||
} |
||||
if m.Disabled { |
||||
dAtA[i] = 0x20 |
||||
i++ |
||||
if m.Disabled { |
||||
dAtA[i] = 1 |
||||
} else { |
||||
dAtA[i] = 0 |
||||
} |
||||
i++ |
||||
} |
||||
if len(m.Env) > 0 { |
||||
for _, s := range m.Env { |
||||
dAtA[i] = 0x2a |
||||
i++ |
||||
l = len(s) |
||||
for l >= 1<<7 { |
||||
dAtA[i] = uint8(uint64(l)&0x7f | 0x80) |
||||
l >>= 7 |
||||
i++ |
||||
} |
||||
dAtA[i] = uint8(l) |
||||
i++ |
||||
i += copy(dAtA[i:], s) |
||||
} |
||||
} |
||||
return i, nil |
||||
} |
||||
|
||||
func (m *PluginPrivilege) Marshal() (dAtA []byte, err error) { |
||||
size := m.Size() |
||||
dAtA = make([]byte, size) |
||||
n, err := m.MarshalTo(dAtA) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
return dAtA[:n], nil |
||||
} |
||||
|
||||
func (m *PluginPrivilege) MarshalTo(dAtA []byte) (int, error) { |
||||
var i int |
||||
_ = i |
||||
var l int |
||||
_ = l |
||||
if len(m.Name) > 0 { |
||||
dAtA[i] = 0xa |
||||
i++ |
||||
i = encodeVarintPlugin(dAtA, i, uint64(len(m.Name))) |
||||
i += copy(dAtA[i:], m.Name) |
||||
} |
||||
if len(m.Description) > 0 { |
||||
dAtA[i] = 0x12 |
||||
i++ |
||||
i = encodeVarintPlugin(dAtA, i, uint64(len(m.Description))) |
||||
i += copy(dAtA[i:], m.Description) |
||||
} |
||||
if len(m.Value) > 0 { |
||||
for _, s := range m.Value { |
||||
dAtA[i] = 0x1a |
||||
i++ |
||||
l = len(s) |
||||
for l >= 1<<7 { |
||||
dAtA[i] = uint8(uint64(l)&0x7f | 0x80) |
||||
l >>= 7 |
||||
i++ |
||||
} |
||||
dAtA[i] = uint8(l) |
||||
i++ |
||||
i += copy(dAtA[i:], s) |
||||
} |
||||
} |
||||
return i, nil |
||||
} |
||||
|
||||
func encodeVarintPlugin(dAtA []byte, offset int, v uint64) int { |
||||
for v >= 1<<7 { |
||||
dAtA[offset] = uint8(v&0x7f | 0x80) |
||||
v >>= 7 |
||||
offset++ |
||||
} |
||||
dAtA[offset] = uint8(v) |
||||
return offset + 1 |
||||
} |
||||
func (m *PluginSpec) Size() (n int) { |
||||
var l int |
||||
_ = l |
||||
l = len(m.Name) |
||||
if l > 0 { |
||||
n += 1 + l + sovPlugin(uint64(l)) |
||||
} |
||||
l = len(m.Remote) |
||||
if l > 0 { |
||||
n += 1 + l + sovPlugin(uint64(l)) |
||||
} |
||||
if len(m.Privileges) > 0 { |
||||
for _, e := range m.Privileges { |
||||
l = e.Size() |
||||
n += 1 + l + sovPlugin(uint64(l)) |
||||
} |
||||
} |
||||
if m.Disabled { |
||||
n += 2 |
||||
} |
||||
if len(m.Env) > 0 { |
||||
for _, s := range m.Env { |
||||
l = len(s) |
||||
n += 1 + l + sovPlugin(uint64(l)) |
||||
} |
||||
} |
||||
return n |
||||
} |
||||
|
||||
func (m *PluginPrivilege) Size() (n int) { |
||||
var l int |
||||
_ = l |
||||
l = len(m.Name) |
||||
if l > 0 { |
||||
n += 1 + l + sovPlugin(uint64(l)) |
||||
} |
||||
l = len(m.Description) |
||||
if l > 0 { |
||||
n += 1 + l + sovPlugin(uint64(l)) |
||||
} |
||||
if len(m.Value) > 0 { |
||||
for _, s := range m.Value { |
||||
l = len(s) |
||||
n += 1 + l + sovPlugin(uint64(l)) |
||||
} |
||||
} |
||||
return n |
||||
} |
||||
|
||||
func sovPlugin(x uint64) (n int) { |
||||
for { |
||||
n++ |
||||
x >>= 7 |
||||
if x == 0 { |
||||
break |
||||
} |
||||
} |
||||
return n |
||||
} |
||||
func sozPlugin(x uint64) (n int) { |
||||
return sovPlugin(uint64((x << 1) ^ uint64((int64(x) >> 63)))) |
||||
} |
||||
func (m *PluginSpec) Unmarshal(dAtA []byte) error { |
||||
l := len(dAtA) |
||||
iNdEx := 0 |
||||
for iNdEx < l { |
||||
preIndex := iNdEx |
||||
var wire uint64 |
||||
for shift := uint(0); ; shift += 7 { |
||||
if shift >= 64 { |
||||
return ErrIntOverflowPlugin |
||||
} |
||||
if iNdEx >= l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
b := dAtA[iNdEx] |
||||
iNdEx++ |
||||
wire |= (uint64(b) & 0x7F) << shift |
||||
if b < 0x80 { |
||||
break |
||||
} |
||||
} |
||||
fieldNum := int32(wire >> 3) |
||||
wireType := int(wire & 0x7) |
||||
if wireType == 4 { |
||||
return fmt.Errorf("proto: PluginSpec: wiretype end group for non-group") |
||||
} |
||||
if fieldNum <= 0 { |
||||
return fmt.Errorf("proto: PluginSpec: illegal tag %d (wire type %d)", fieldNum, wire) |
||||
} |
||||
switch fieldNum { |
||||
case 1: |
||||
if wireType != 2 { |
||||
return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) |
||||
} |
||||
var stringLen uint64 |
||||
for shift := uint(0); ; shift += 7 { |
||||
if shift >= 64 { |
||||
return ErrIntOverflowPlugin |
||||
} |
||||
if iNdEx >= l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
b := dAtA[iNdEx] |
||||
iNdEx++ |
||||
stringLen |= (uint64(b) & 0x7F) << shift |
||||
if b < 0x80 { |
||||
break |
||||
} |
||||
} |
||||
intStringLen := int(stringLen) |
||||
if intStringLen < 0 { |
||||
return ErrInvalidLengthPlugin |
||||
} |
||||
postIndex := iNdEx + intStringLen |
||||
if postIndex > l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
m.Name = string(dAtA[iNdEx:postIndex]) |
||||
iNdEx = postIndex |
||||
case 2: |
||||
if wireType != 2 { |
||||
return fmt.Errorf("proto: wrong wireType = %d for field Remote", wireType) |
||||
} |
||||
var stringLen uint64 |
||||
for shift := uint(0); ; shift += 7 { |
||||
if shift >= 64 { |
||||
return ErrIntOverflowPlugin |
||||
} |
||||
if iNdEx >= l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
b := dAtA[iNdEx] |
||||
iNdEx++ |
||||
stringLen |= (uint64(b) & 0x7F) << shift |
||||
if b < 0x80 { |
||||
break |
||||
} |
||||
} |
||||
intStringLen := int(stringLen) |
||||
if intStringLen < 0 { |
||||
return ErrInvalidLengthPlugin |
||||
} |
||||
postIndex := iNdEx + intStringLen |
||||
if postIndex > l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
m.Remote = string(dAtA[iNdEx:postIndex]) |
||||
iNdEx = postIndex |
||||
case 3: |
||||
if wireType != 2 { |
||||
return fmt.Errorf("proto: wrong wireType = %d for field Privileges", wireType) |
||||
} |
||||
var msglen int |
||||
for shift := uint(0); ; shift += 7 { |
||||
if shift >= 64 { |
||||
return ErrIntOverflowPlugin |
||||
} |
||||
if iNdEx >= l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
b := dAtA[iNdEx] |
||||
iNdEx++ |
||||
msglen |= (int(b) & 0x7F) << shift |
||||
if b < 0x80 { |
||||
break |
||||
} |
||||
} |
||||
if msglen < 0 { |
||||
return ErrInvalidLengthPlugin |
||||
} |
||||
postIndex := iNdEx + msglen |
||||
if postIndex > l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
m.Privileges = append(m.Privileges, &PluginPrivilege{}) |
||||
if err := m.Privileges[len(m.Privileges)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { |
||||
return err |
||||
} |
||||
iNdEx = postIndex |
||||
case 4: |
||||
if wireType != 0 { |
||||
return fmt.Errorf("proto: wrong wireType = %d for field Disabled", wireType) |
||||
} |
||||
var v int |
||||
for shift := uint(0); ; shift += 7 { |
||||
if shift >= 64 { |
||||
return ErrIntOverflowPlugin |
||||
} |
||||
if iNdEx >= l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
b := dAtA[iNdEx] |
||||
iNdEx++ |
||||
v |= (int(b) & 0x7F) << shift |
||||
if b < 0x80 { |
||||
break |
||||
} |
||||
} |
||||
m.Disabled = bool(v != 0) |
||||
case 5: |
||||
if wireType != 2 { |
||||
return fmt.Errorf("proto: wrong wireType = %d for field Env", wireType) |
||||
} |
||||
var stringLen uint64 |
||||
for shift := uint(0); ; shift += 7 { |
||||
if shift >= 64 { |
||||
return ErrIntOverflowPlugin |
||||
} |
||||
if iNdEx >= l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
b := dAtA[iNdEx] |
||||
iNdEx++ |
||||
stringLen |= (uint64(b) & 0x7F) << shift |
||||
if b < 0x80 { |
||||
break |
||||
} |
||||
} |
||||
intStringLen := int(stringLen) |
||||
if intStringLen < 0 { |
||||
return ErrInvalidLengthPlugin |
||||
} |
||||
postIndex := iNdEx + intStringLen |
||||
if postIndex > l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
m.Env = append(m.Env, string(dAtA[iNdEx:postIndex])) |
||||
iNdEx = postIndex |
||||
default: |
||||
iNdEx = preIndex |
||||
skippy, err := skipPlugin(dAtA[iNdEx:]) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
if skippy < 0 { |
||||
return ErrInvalidLengthPlugin |
||||
} |
||||
if (iNdEx + skippy) > l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
iNdEx += skippy |
||||
} |
||||
} |
||||
|
||||
if iNdEx > l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
return nil |
||||
} |
||||
func (m *PluginPrivilege) Unmarshal(dAtA []byte) error { |
||||
l := len(dAtA) |
||||
iNdEx := 0 |
||||
for iNdEx < l { |
||||
preIndex := iNdEx |
||||
var wire uint64 |
||||
for shift := uint(0); ; shift += 7 { |
||||
if shift >= 64 { |
||||
return ErrIntOverflowPlugin |
||||
} |
||||
if iNdEx >= l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
b := dAtA[iNdEx] |
||||
iNdEx++ |
||||
wire |= (uint64(b) & 0x7F) << shift |
||||
if b < 0x80 { |
||||
break |
||||
} |
||||
} |
||||
fieldNum := int32(wire >> 3) |
||||
wireType := int(wire & 0x7) |
||||
if wireType == 4 { |
||||
return fmt.Errorf("proto: PluginPrivilege: wiretype end group for non-group") |
||||
} |
||||
if fieldNum <= 0 { |
||||
return fmt.Errorf("proto: PluginPrivilege: illegal tag %d (wire type %d)", fieldNum, wire) |
||||
} |
||||
switch fieldNum { |
||||
case 1: |
||||
if wireType != 2 { |
||||
return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) |
||||
} |
||||
var stringLen uint64 |
||||
for shift := uint(0); ; shift += 7 { |
||||
if shift >= 64 { |
||||
return ErrIntOverflowPlugin |
||||
} |
||||
if iNdEx >= l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
b := dAtA[iNdEx] |
||||
iNdEx++ |
||||
stringLen |= (uint64(b) & 0x7F) << shift |
||||
if b < 0x80 { |
||||
break |
||||
} |
||||
} |
||||
intStringLen := int(stringLen) |
||||
if intStringLen < 0 { |
||||
return ErrInvalidLengthPlugin |
||||
} |
||||
postIndex := iNdEx + intStringLen |
||||
if postIndex > l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
m.Name = string(dAtA[iNdEx:postIndex]) |
||||
iNdEx = postIndex |
||||
case 2: |
||||
if wireType != 2 { |
||||
return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) |
||||
} |
||||
var stringLen uint64 |
||||
for shift := uint(0); ; shift += 7 { |
||||
if shift >= 64 { |
||||
return ErrIntOverflowPlugin |
||||
} |
||||
if iNdEx >= l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
b := dAtA[iNdEx] |
||||
iNdEx++ |
||||
stringLen |= (uint64(b) & 0x7F) << shift |
||||
if b < 0x80 { |
||||
break |
||||
} |
||||
} |
||||
intStringLen := int(stringLen) |
||||
if intStringLen < 0 { |
||||
return ErrInvalidLengthPlugin |
||||
} |
||||
postIndex := iNdEx + intStringLen |
||||
if postIndex > l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
m.Description = string(dAtA[iNdEx:postIndex]) |
||||
iNdEx = postIndex |
||||
case 3: |
||||
if wireType != 2 { |
||||
return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) |
||||
} |
||||
var stringLen uint64 |
||||
for shift := uint(0); ; shift += 7 { |
||||
if shift >= 64 { |
||||
return ErrIntOverflowPlugin |
||||
} |
||||
if iNdEx >= l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
b := dAtA[iNdEx] |
||||
iNdEx++ |
||||
stringLen |= (uint64(b) & 0x7F) << shift |
||||
if b < 0x80 { |
||||
break |
||||
} |
||||
} |
||||
intStringLen := int(stringLen) |
||||
if intStringLen < 0 { |
||||
return ErrInvalidLengthPlugin |
||||
} |
||||
postIndex := iNdEx + intStringLen |
||||
if postIndex > l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
m.Value = append(m.Value, string(dAtA[iNdEx:postIndex])) |
||||
iNdEx = postIndex |
||||
default: |
||||
iNdEx = preIndex |
||||
skippy, err := skipPlugin(dAtA[iNdEx:]) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
if skippy < 0 { |
||||
return ErrInvalidLengthPlugin |
||||
} |
||||
if (iNdEx + skippy) > l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
iNdEx += skippy |
||||
} |
||||
} |
||||
|
||||
if iNdEx > l { |
||||
return io.ErrUnexpectedEOF |
||||
} |
||||
return nil |
||||
} |
||||
func skipPlugin(dAtA []byte) (n int, err error) { |
||||
l := len(dAtA) |
||||
iNdEx := 0 |
||||
for iNdEx < l { |
||||
var wire uint64 |
||||
for shift := uint(0); ; shift += 7 { |
||||
if shift >= 64 { |
||||
return 0, ErrIntOverflowPlugin |
||||
} |
||||
if iNdEx >= l { |
||||
return 0, io.ErrUnexpectedEOF |
||||
} |
||||
b := dAtA[iNdEx] |
||||
iNdEx++ |
||||
wire |= (uint64(b) & 0x7F) << shift |
||||
if b < 0x80 { |
||||
break |
||||
} |
||||
} |
||||
wireType := int(wire & 0x7) |
||||
switch wireType { |
||||
case 0: |
||||
for shift := uint(0); ; shift += 7 { |
||||
if shift >= 64 { |
||||
return 0, ErrIntOverflowPlugin |
||||
} |
||||
if iNdEx >= l { |
||||
return 0, io.ErrUnexpectedEOF |
||||
} |
||||
iNdEx++ |
||||
if dAtA[iNdEx-1] < 0x80 { |
||||
break |
||||
} |
||||
} |
||||
return iNdEx, nil |
||||
case 1: |
||||
iNdEx += 8 |
||||
return iNdEx, nil |
||||
case 2: |
||||
var length int |
||||
for shift := uint(0); ; shift += 7 { |
||||
if shift >= 64 { |
||||
return 0, ErrIntOverflowPlugin |
||||
} |
||||
if iNdEx >= l { |
||||
return 0, io.ErrUnexpectedEOF |
||||
} |
||||
b := dAtA[iNdEx] |
||||
iNdEx++ |
||||
length |= (int(b) & 0x7F) << shift |
||||
if b < 0x80 { |
||||
break |
||||
} |
||||
} |
||||
iNdEx += length |
||||
if length < 0 { |
||||
return 0, ErrInvalidLengthPlugin |
||||
} |
||||
return iNdEx, nil |
||||
case 3: |
||||
for { |
||||
var innerWire uint64 |
||||
var start int = iNdEx |
||||
for shift := uint(0); ; shift += 7 { |
||||
if shift >= 64 { |
||||
return 0, ErrIntOverflowPlugin |
||||
} |
||||
if iNdEx >= l { |
||||
return 0, io.ErrUnexpectedEOF |
||||
} |
||||
b := dAtA[iNdEx] |
||||
iNdEx++ |
||||
innerWire |= (uint64(b) & 0x7F) << shift |
||||
if b < 0x80 { |
||||
break |
||||
} |
||||
} |
||||
innerWireType := int(innerWire & 0x7) |
||||
if innerWireType == 4 { |
||||
break |
||||
} |
||||
next, err := skipPlugin(dAtA[start:]) |
||||
if err != nil { |
||||
return 0, err |
||||
} |
||||
iNdEx = start + next |
||||
} |
||||
return iNdEx, nil |
||||
case 4: |
||||
return iNdEx, nil |
||||
case 5: |
||||
iNdEx += 4 |
||||
return iNdEx, nil |
||||
default: |
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType) |
||||
} |
||||
} |
||||
panic("unreachable") |
||||
} |
||||
|
||||
var ( |
||||
ErrInvalidLengthPlugin = fmt.Errorf("proto: negative length found during unmarshaling") |
||||
ErrIntOverflowPlugin = fmt.Errorf("proto: integer overflow") |
||||
) |
||||
|
||||
func init() { proto.RegisterFile("plugin.proto", fileDescriptorPlugin) } |
||||
|
||||
var fileDescriptorPlugin = []byte{ |
||||
// 256 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x4d, 0x4b, 0xc3, 0x30, |
||||
0x18, 0xc7, 0x89, 0xdd, 0xc6, 0xfa, 0x4c, 0x70, 0x04, 0x91, 0xe2, 0xa1, 0x94, 0x9d, 0x7a, 0x6a, |
||||
0x45, 0x2f, 0x82, 0x37, 0x0f, 0x9e, 0x47, 0xbc, 0x09, 0x1e, 0xd2, 0xf6, 0xa1, 0x06, 0x9b, 0x17, |
||||
0x92, 0xb4, 0xe2, 0x37, 0xf1, 0x23, 0x79, 0xf4, 0x23, 0x48, 0x3f, 0x89, 0x98, 0x75, 0x32, 0x64, |
||||
0xa7, 0xff, 0x4b, 0xc2, 0x9f, 0x1f, 0x0f, 0x9c, 0x9a, 0xae, 0x6f, 0x85, 0x2a, 0x8c, 0xd5, 0x5e, |
||||
0x6f, 0x3e, 0x08, 0xc0, 0x36, 0x14, 0x8f, 0x06, 0x6b, 0x4a, 0x61, 0xa6, 0xb8, 0xc4, 0x84, 0x64, |
||||
0x24, 0x8f, 0x59, 0xf0, 0xf4, 0x02, 0x16, 0x16, 0xa5, 0xf6, 0x98, 0x9c, 0x84, 0x76, 0x4a, 0xf4, |
||||
0x0a, 0xc0, 0x58, 0x31, 0x88, 0x0e, 0x5b, 0x74, 0x49, 0x94, 0x45, 0xf9, 0xea, 0x7a, 0x5d, 0xec, |
||||
0xc6, 0xb6, 0xfb, 0x07, 0x76, 0xf0, 0x87, 0x5e, 0xc2, 0xb2, 0x11, 0x8e, 0x57, 0x1d, 0x36, 0xc9, |
||||
0x2c, 0x23, 0xf9, 0x92, 0xfd, 0x65, 0xba, 0x86, 0x08, 0xd5, 0x90, 0xcc, 0xb3, 0x28, 0x8f, 0xd9, |
||||
0xaf, 0xdd, 0x3c, 0xc3, 0xd9, 0xbf, 0xb1, 0xa3, 0x78, 0x19, 0xac, 0x1a, 0x74, 0xb5, 0x15, 0xc6, |
||||
0x0b, 0xad, 0x26, 0xc6, 0xc3, 0x8a, 0x9e, 0xc3, 0x7c, 0xe0, 0x5d, 0x8f, 0x81, 0x31, 0x66, 0xbb, |
||||
0x70, 0xff, 0xf0, 0x39, 0xa6, 0xe4, 0x6b, 0x4c, 0xc9, 0xf7, 0x98, 0x92, 0xa7, 0xdb, 0x56, 0xf8, |
||||
0x97, 0xbe, 0x2a, 0x6a, 0x2d, 0xcb, 0x46, 0xd7, 0xaf, 0x68, 0xf7, 0xc2, 0x8d, 0x28, 0xfd, 0xbb, |
||||
0x41, 0x57, 0xba, 0x37, 0x6e, 0x65, 0x69, 0x7b, 0xe5, 0x85, 0xc4, 0xbb, 0x49, 0xab, 0x45, 0x38, |
||||
0xe4, 0xcd, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x99, 0xa8, 0xd9, 0x9b, 0x58, 0x01, 0x00, 0x00, |
||||
} |
@ -0,0 +1,21 @@ |
||||
syntax = "proto3"; |
||||
|
||||
option go_package = "github.com/docker/docker/api/types/swarm/runtime;runtime"; |
||||
|
||||
// PluginSpec defines the base payload which clients can specify for creating |
||||
// a service with the plugin runtime. |
||||
message PluginSpec { |
||||
string name = 1; |
||||
string remote = 2; |
||||
repeated PluginPrivilege privileges = 3; |
||||
bool disabled = 4; |
||||
repeated string env = 5; |
||||
} |
||||
|
||||
// PluginPrivilege describes a permission the user has to accept |
||||
// upon installing a plugin. |
||||
message PluginPrivilege { |
||||
string name = 1; |
||||
string description = 2; |
||||
repeated string value = 3; |
||||
} |
@ -1,15 +1,15 @@ |
||||
package volume |
||||
package volume // import "github.com/docker/docker/api/types/volume"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// DO NOT EDIT THIS FILE
|
||||
// This file was generated by `swagger generate operation`
|
||||
//
|
||||
// See hack/swagger-gen.sh
|
||||
// See hack/generate-swagger-api.sh
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// VolumesCreateBody volumes create body
|
||||
// swagger:model VolumesCreateBody
|
||||
type VolumesCreateBody struct { |
||||
// VolumeCreateBody Volume configuration
|
||||
// swagger:model VolumeCreateBody
|
||||
type VolumeCreateBody struct { |
||||
|
||||
// Name of the volume driver to use.
|
||||
// Required: true
|
@ -1,17 +1,17 @@ |
||||
package volume |
||||
package volume // import "github.com/docker/docker/api/types/volume"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// DO NOT EDIT THIS FILE
|
||||
// This file was generated by `swagger generate operation`
|
||||
//
|
||||
// See hack/swagger-gen.sh
|
||||
// See hack/generate-swagger-api.sh
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
import "github.com/docker/docker/api/types" |
||||
|
||||
// VolumesListOKBody volumes list o k body
|
||||
// swagger:model VolumesListOKBody
|
||||
type VolumesListOKBody struct { |
||||
// VolumeListOKBody Volume list response
|
||||
// swagger:model VolumeListOKBody
|
||||
type VolumeListOKBody struct { |
||||
|
||||
// List of volumes
|
||||
// Required: true
|
@ -0,0 +1,16 @@ |
||||
package client // import "github.com/docker/docker/client"
|
||||
|
||||
import ( |
||||
"context" |
||||
"net/url" |
||||
) |
||||
|
||||
// BuildCancel requests the daemon to cancel ongoing build request
|
||||
func (cli *Client) BuildCancel(ctx context.Context, id string) error { |
||||
query := url.Values{} |
||||
query.Set("id", id) |
||||
|
||||
serverResp, err := cli.post(ctx, "/build/cancel", query, nil, nil) |
||||
ensureReaderClosed(serverResp) |
||||
return err |
||||
} |
@ -0,0 +1,45 @@ |
||||
package client // import "github.com/docker/docker/client"
|
||||
|
||||
import ( |
||||
"context" |
||||
"encoding/json" |
||||
"fmt" |
||||
"net/url" |
||||
|
||||
"github.com/docker/docker/api/types" |
||||
"github.com/docker/docker/api/types/filters" |
||||
"github.com/pkg/errors" |
||||
) |
||||
|
||||
// BuildCachePrune requests the daemon to delete unused cache data
|
||||
func (cli *Client) BuildCachePrune(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error) { |
||||
if err := cli.NewVersionError("1.31", "build prune"); err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
report := types.BuildCachePruneReport{} |
||||
|
||||
query := url.Values{} |
||||
if opts.All { |
||||
query.Set("all", "1") |
||||
} |
||||
query.Set("keep-storage", fmt.Sprintf("%d", opts.KeepStorage)) |
||||
filters, err := filters.ToJSON(opts.Filters) |
||||
if err != nil { |
||||
return nil, errors.Wrap(err, "prune could not marshal filters option") |
||||
} |
||||
query.Set("filters", filters) |
||||
|
||||
serverResp, err := cli.post(ctx, "/build/prune", query, nil, nil) |
||||
defer ensureReaderClosed(serverResp) |
||||
|
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
if err := json.NewDecoder(serverResp.body).Decode(&report); err != nil { |
||||
return nil, fmt.Errorf("Error retrieving disk usage: %v", err) |
||||
} |
||||
|
||||
return &report, nil |
||||
} |
@ -0,0 +1,23 @@ |
||||
package client |
||||
|
||||
import "net/http" |
||||
|
||||
// NewClient initializes a new API client for the given host and API version.
|
||||
// It uses the given http client as transport.
|
||||
// It also initializes the custom http headers to add to each request.
|
||||
//
|
||||
// It won't send any version information if the version number is empty. It is
|
||||
// highly recommended that you set a version or your client may break if the
|
||||
// server is upgraded.
|
||||
// Deprecated: use NewClientWithOpts
|
||||
func NewClient(host string, version string, client *http.Client, httpHeaders map[string]string) (*Client, error) { |
||||
return NewClientWithOpts(WithHost(host), WithVersion(version), WithHTTPClient(client), WithHTTPHeaders(httpHeaders)) |
||||
} |
||||
|
||||
// NewEnvClient initializes a new API client based on environment variables.
|
||||
// See FromEnv for a list of support environment variables.
|
||||
//
|
||||
// Deprecated: use NewClientWithOpts(FromEnv)
|
||||
func NewEnvClient() (*Client, error) { |
||||
return NewClientWithOpts(FromEnv) |
||||
} |
@ -1,6 +1,9 @@ |
||||
// +build linux freebsd solaris openbsd darwin
|
||||
// +build linux freebsd openbsd darwin
|
||||
|
||||
package client |
||||
package client // import "github.com/docker/docker/client"
|
||||
|
||||
// DefaultDockerHost defines os specific default if DOCKER_HOST is unset
|
||||
const DefaultDockerHost = "unix:///var/run/docker.sock" |
||||
|
||||
const defaultProto = "unix" |
||||
const defaultAddr = "/var/run/docker.sock" |
||||
|
@ -1,4 +1,7 @@ |
||||
package client |
||||
package client // import "github.com/docker/docker/client"
|
||||
|
||||
// DefaultDockerHost defines os specific default if DOCKER_HOST is unset
|
||||
const DefaultDockerHost = "npipe:////./pipe/docker_engine" |
||||
|
||||
const defaultProto = "npipe" |
||||
const defaultAddr = "//./pipe/docker_engine" |
||||
|
@ -0,0 +1,25 @@ |
||||
package client // import "github.com/docker/docker/client"
|
||||
|
||||
import ( |
||||
"context" |
||||
"encoding/json" |
||||
|
||||
"github.com/docker/docker/api/types" |
||||
"github.com/docker/docker/api/types/swarm" |
||||
) |
||||
|
||||
// ConfigCreate creates a new Config.
|
||||
func (cli *Client) ConfigCreate(ctx context.Context, config swarm.ConfigSpec) (types.ConfigCreateResponse, error) { |
||||
var response types.ConfigCreateResponse |
||||
if err := cli.NewVersionError("1.30", "config create"); err != nil { |
||||
return response, err |
||||
} |
||||
resp, err := cli.post(ctx, "/configs/create", nil, config, nil) |
||||
defer ensureReaderClosed(resp) |
||||
if err != nil { |
||||
return response, err |
||||
} |
||||
|
||||
err = json.NewDecoder(resp.body).Decode(&response) |
||||
return response, err |
||||
} |
@ -0,0 +1,36 @@ |
||||
package client // import "github.com/docker/docker/client"
|
||||
|
||||
import ( |
||||
"bytes" |
||||
"context" |
||||
"encoding/json" |
||||
"io/ioutil" |
||||
|
||||
"github.com/docker/docker/api/types/swarm" |
||||
) |
||||
|
||||
// ConfigInspectWithRaw returns the config information with raw data
|
||||
func (cli *Client) ConfigInspectWithRaw(ctx context.Context, id string) (swarm.Config, []byte, error) { |
||||
if id == "" { |
||||
return swarm.Config{}, nil, objectNotFoundError{object: "config", id: id} |
||||
} |
||||
if err := cli.NewVersionError("1.30", "config inspect"); err != nil { |
||||
return swarm.Config{}, nil, err |
||||
} |
||||
resp, err := cli.get(ctx, "/configs/"+id, nil, nil) |
||||
defer ensureReaderClosed(resp) |
||||
if err != nil { |
||||
return swarm.Config{}, nil, wrapResponseError(err, resp, "config", id) |
||||
} |
||||
|
||||
body, err := ioutil.ReadAll(resp.body) |
||||
if err != nil { |
||||
return swarm.Config{}, nil, err |
||||
} |
||||
|
||||
var config swarm.Config |
||||
rdr := bytes.NewReader(body) |
||||
err = json.NewDecoder(rdr).Decode(&config) |
||||
|
||||
return config, body, err |
||||
} |
@ -0,0 +1,38 @@ |
||||
package client // import "github.com/docker/docker/client"
|
||||
|
||||
import ( |
||||
"context" |
||||
"encoding/json" |
||||
"net/url" |
||||
|
||||
"github.com/docker/docker/api/types" |
||||
"github.com/docker/docker/api/types/filters" |
||||
"github.com/docker/docker/api/types/swarm" |
||||
) |
||||
|
||||
// ConfigList returns the list of configs.
|
||||
func (cli *Client) ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error) { |
||||
if err := cli.NewVersionError("1.30", "config list"); err != nil { |
||||
return nil, err |
||||
} |
||||
query := url.Values{} |
||||
|
||||
if options.Filters.Len() > 0 { |
||||
filterJSON, err := filters.ToJSON(options.Filters) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
query.Set("filters", filterJSON) |
||||
} |
||||
|
||||
resp, err := cli.get(ctx, "/configs", query, nil) |
||||
defer ensureReaderClosed(resp) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
var configs []swarm.Config |
||||
err = json.NewDecoder(resp.body).Decode(&configs) |
||||
return configs, err |
||||
} |
@ -0,0 +1,13 @@ |
||||
package client // import "github.com/docker/docker/client"
|
||||
|
||||
import "context" |
||||
|
||||
// ConfigRemove removes a Config.
|
||||
func (cli *Client) ConfigRemove(ctx context.Context, id string) error { |
||||
if err := cli.NewVersionError("1.30", "config remove"); err != nil { |
||||
return err |
||||
} |
||||
resp, err := cli.delete(ctx, "/configs/"+id, nil, nil) |
||||
defer ensureReaderClosed(resp) |
||||
return wrapResponseError(err, resp, "config", id) |
||||
} |
@ -0,0 +1,21 @@ |
||||
package client // import "github.com/docker/docker/client"
|
||||
|
||||
import ( |
||||
"context" |
||||
"net/url" |
||||
"strconv" |
||||
|
||||
"github.com/docker/docker/api/types/swarm" |
||||
) |
||||
|
||||
// ConfigUpdate attempts to update a Config
|
||||
func (cli *Client) ConfigUpdate(ctx context.Context, id string, version swarm.Version, config swarm.ConfigSpec) error { |
||||
if err := cli.NewVersionError("1.30", "config update"); err != nil { |
||||
return err |
||||
} |
||||
query := url.Values{} |
||||
query.Set("version", strconv.FormatUint(version.Index, 10)) |
||||
resp, err := cli.post(ctx, "/configs/"+id+"/update", query, config, nil) |
||||
ensureReaderClosed(resp) |
||||
return err |
||||
} |
@ -1,23 +1,23 @@ |
||||
package client |
||||
package client // import "github.com/docker/docker/client"
|
||||
|
||||
import ( |
||||
"context" |
||||
"encoding/json" |
||||
"net/url" |
||||
|
||||
"github.com/docker/docker/api/types" |
||||
"golang.org/x/net/context" |
||||
"github.com/docker/docker/api/types/container" |
||||
) |
||||
|
||||
// ContainerDiff shows differences in a container filesystem since it was started.
|
||||
func (cli *Client) ContainerDiff(ctx context.Context, containerID string) ([]types.ContainerChange, error) { |
||||
var changes []types.ContainerChange |
||||
func (cli *Client) ContainerDiff(ctx context.Context, containerID string) ([]container.ContainerChangeResponseItem, error) { |
||||
var changes []container.ContainerChangeResponseItem |
||||
|
||||
serverResp, err := cli.get(ctx, "/containers/"+containerID+"/changes", url.Values{}, nil) |
||||
defer ensureReaderClosed(serverResp) |
||||
if err != nil { |
||||
return changes, err |
||||
} |
||||
|
||||
err = json.NewDecoder(serverResp.body).Decode(&changes) |
||||
ensureReaderClosed(serverResp) |
||||
return changes, err |
||||
} |
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue