mirror of
https://github.com/containers/skopeo.git
synced 2025-08-12 03:42:14 +00:00
s/interface{}/any/g
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
parent
f2b3a9c04b
commit
891ba3d4a6
@ -74,7 +74,7 @@ func (opts *inspectOptions) run(args []string, stdout io.Writer) (retErr error)
|
|||||||
rawManifest []byte
|
rawManifest []byte
|
||||||
src types.ImageSource
|
src types.ImageSource
|
||||||
imgInspect *types.ImageInspectInfo
|
imgInspect *types.ImageInspectInfo
|
||||||
data []interface{}
|
data []any
|
||||||
)
|
)
|
||||||
ctx, cancel := opts.global.commandTimeoutContext()
|
ctx, cancel := opts.global.commandTimeoutContext()
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@ -240,7 +240,7 @@ func (opts *inspectOptions) run(args []string, stdout io.Writer) (retErr error)
|
|||||||
return printTmpl(stdout, row, data)
|
return printTmpl(stdout, row, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func printTmpl(stdout io.Writer, row string, data []interface{}) error {
|
func printTmpl(stdout io.Writer, row string, data []any) error {
|
||||||
t, err := template.New("skopeo inspect").Parse(row)
|
t, err := template.New("skopeo inspect").Parse(row)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -115,7 +115,7 @@ type request struct {
|
|||||||
// Method is the name of the function
|
// Method is the name of the function
|
||||||
Method string `json:"method"`
|
Method string `json:"method"`
|
||||||
// Args is the arguments (parsed inside the function)
|
// Args is the arguments (parsed inside the function)
|
||||||
Args []interface{} `json:"args"`
|
Args []any `json:"args"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// reply is serialized to JSON as the return value from a function call.
|
// reply is serialized to JSON as the return value from a function call.
|
||||||
@ -123,7 +123,7 @@ type reply struct {
|
|||||||
// Success is true if and only if the call succeeded.
|
// Success is true if and only if the call succeeded.
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
// Value is an arbitrary value (or values, as array/map) returned from the call.
|
// Value is an arbitrary value (or values, as array/map) returned from the call.
|
||||||
Value interface{} `json:"value"`
|
Value any `json:"value"`
|
||||||
// PipeID is an index into open pipes, and should be passed to FinishPipe
|
// PipeID is an index into open pipes, and should be passed to FinishPipe
|
||||||
PipeID uint32 `json:"pipeid"`
|
PipeID uint32 `json:"pipeid"`
|
||||||
// Error should be non-empty if Success == false
|
// Error should be non-empty if Success == false
|
||||||
@ -133,7 +133,7 @@ type reply struct {
|
|||||||
// replyBuf is our internal deserialization of reply plus optional fd
|
// replyBuf is our internal deserialization of reply plus optional fd
|
||||||
type replyBuf struct {
|
type replyBuf struct {
|
||||||
// value will be converted to a reply Value
|
// value will be converted to a reply Value
|
||||||
value interface{}
|
value any
|
||||||
// fd is the read half of a pipe, passed back to the client
|
// fd is the read half of a pipe, passed back to the client
|
||||||
fd *os.File
|
fd *os.File
|
||||||
// pipeid will be provided to the client as PipeID, an index into our open pipes
|
// pipeid will be provided to the client as PipeID, an index into our open pipes
|
||||||
@ -185,7 +185,7 @@ type convertedLayerInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize performs one-time initialization, and returns the protocol version
|
// Initialize performs one-time initialization, and returns the protocol version
|
||||||
func (h *proxyHandler) Initialize(args []interface{}) (replyBuf, error) {
|
func (h *proxyHandler) Initialize(args []any) (replyBuf, error) {
|
||||||
h.lock.Lock()
|
h.lock.Lock()
|
||||||
defer h.lock.Unlock()
|
defer h.lock.Unlock()
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ func (h *proxyHandler) Initialize(args []interface{}) (replyBuf, error) {
|
|||||||
|
|
||||||
// OpenImage accepts a string image reference i.e. TRANSPORT:REF - like `skopeo copy`.
|
// OpenImage accepts a string image reference i.e. TRANSPORT:REF - like `skopeo copy`.
|
||||||
// The return value is an opaque integer handle.
|
// The return value is an opaque integer handle.
|
||||||
func (h *proxyHandler) OpenImage(args []interface{}) (replyBuf, error) {
|
func (h *proxyHandler) OpenImage(args []any) (replyBuf, error) {
|
||||||
return h.openImageImpl(args, false)
|
return h.openImageImpl(args, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ func isNotFoundImageError(err error) bool {
|
|||||||
errors.Is(err, ocilayout.ImageNotFoundError{})
|
errors.Is(err, ocilayout.ImageNotFoundError{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *proxyHandler) openImageImpl(args []interface{}, allowNotFound bool) (replyBuf, error) {
|
func (h *proxyHandler) openImageImpl(args []any, allowNotFound bool) (replyBuf, error) {
|
||||||
h.lock.Lock()
|
h.lock.Lock()
|
||||||
defer h.lock.Unlock()
|
defer h.lock.Unlock()
|
||||||
var ret replyBuf
|
var ret replyBuf
|
||||||
@ -282,11 +282,11 @@ func (h *proxyHandler) openImageImpl(args []interface{}, allowNotFound bool) (re
|
|||||||
// OpenImage accepts a string image reference i.e. TRANSPORT:REF - like `skopeo copy`.
|
// OpenImage accepts a string image reference i.e. TRANSPORT:REF - like `skopeo copy`.
|
||||||
// The return value is an opaque integer handle. If the image does not exist, zero
|
// The return value is an opaque integer handle. If the image does not exist, zero
|
||||||
// is returned.
|
// is returned.
|
||||||
func (h *proxyHandler) OpenImageOptional(args []interface{}) (replyBuf, error) {
|
func (h *proxyHandler) OpenImageOptional(args []any) (replyBuf, error) {
|
||||||
return h.openImageImpl(args, true)
|
return h.openImageImpl(args, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *proxyHandler) CloseImage(args []interface{}) (replyBuf, error) {
|
func (h *proxyHandler) CloseImage(args []any) (replyBuf, error) {
|
||||||
h.lock.Lock()
|
h.lock.Lock()
|
||||||
defer h.lock.Unlock()
|
defer h.lock.Unlock()
|
||||||
var ret replyBuf
|
var ret replyBuf
|
||||||
@ -307,7 +307,7 @@ func (h *proxyHandler) CloseImage(args []interface{}) (replyBuf, error) {
|
|||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseImageID(v interface{}) (uint32, error) {
|
func parseImageID(v any) (uint32, error) {
|
||||||
imgidf, ok := v.(float64)
|
imgidf, ok := v.(float64)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("expecting integer imageid, not %T", v)
|
return 0, fmt.Errorf("expecting integer imageid, not %T", v)
|
||||||
@ -316,7 +316,7 @@ func parseImageID(v interface{}) (uint32, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// parseUint64 validates that a number fits inside a JavaScript safe integer
|
// parseUint64 validates that a number fits inside a JavaScript safe integer
|
||||||
func parseUint64(v interface{}) (uint64, error) {
|
func parseUint64(v any) (uint64, error) {
|
||||||
f, ok := v.(float64)
|
f, ok := v.(float64)
|
||||||
if !ok {
|
if !ok {
|
||||||
return 0, fmt.Errorf("expecting numeric, not %T", v)
|
return 0, fmt.Errorf("expecting numeric, not %T", v)
|
||||||
@ -327,7 +327,7 @@ func parseUint64(v interface{}) (uint64, error) {
|
|||||||
return uint64(f), nil
|
return uint64(f), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *proxyHandler) parseImageFromID(v interface{}) (*openImage, error) {
|
func (h *proxyHandler) parseImageFromID(v any) (*openImage, error) {
|
||||||
imgid, err := parseImageID(v)
|
imgid, err := parseImageID(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -357,7 +357,7 @@ func (h *proxyHandler) allocPipe() (*os.File, *activePipe, error) {
|
|||||||
|
|
||||||
// returnBytes generates a return pipe() from a byte array
|
// returnBytes generates a return pipe() from a byte array
|
||||||
// In the future it might be nicer to return this via memfd_create()
|
// In the future it might be nicer to return this via memfd_create()
|
||||||
func (h *proxyHandler) returnBytes(retval interface{}, buf []byte) (replyBuf, error) {
|
func (h *proxyHandler) returnBytes(retval any, buf []byte) (replyBuf, error) {
|
||||||
var ret replyBuf
|
var ret replyBuf
|
||||||
piper, f, err := h.allocPipe()
|
piper, f, err := h.allocPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -419,7 +419,7 @@ func (h *proxyHandler) cacheTargetManifest(img *openImage) error {
|
|||||||
|
|
||||||
// GetManifest returns a copy of the manifest, converted to OCI format, along with the original digest.
|
// GetManifest returns a copy of the manifest, converted to OCI format, along with the original digest.
|
||||||
// Manifest lists are resolved to the current operating system and architecture.
|
// Manifest lists are resolved to the current operating system and architecture.
|
||||||
func (h *proxyHandler) GetManifest(args []interface{}) (replyBuf, error) {
|
func (h *proxyHandler) GetManifest(args []any) (replyBuf, error) {
|
||||||
h.lock.Lock()
|
h.lock.Lock()
|
||||||
defer h.lock.Unlock()
|
defer h.lock.Unlock()
|
||||||
|
|
||||||
@ -490,7 +490,7 @@ func (h *proxyHandler) GetManifest(args []interface{}) (replyBuf, error) {
|
|||||||
|
|
||||||
// GetFullConfig returns a copy of the image configuration, converted to OCI format.
|
// GetFullConfig returns a copy of the image configuration, converted to OCI format.
|
||||||
// https://github.com/opencontainers/image-spec/blob/main/config.md
|
// https://github.com/opencontainers/image-spec/blob/main/config.md
|
||||||
func (h *proxyHandler) GetFullConfig(args []interface{}) (replyBuf, error) {
|
func (h *proxyHandler) GetFullConfig(args []any) (replyBuf, error) {
|
||||||
h.lock.Lock()
|
h.lock.Lock()
|
||||||
defer h.lock.Unlock()
|
defer h.lock.Unlock()
|
||||||
|
|
||||||
@ -527,7 +527,7 @@ func (h *proxyHandler) GetFullConfig(args []interface{}) (replyBuf, error) {
|
|||||||
// GetConfig returns a copy of the container runtime configuration, converted to OCI format.
|
// GetConfig returns a copy of the container runtime configuration, converted to OCI format.
|
||||||
// Note that due to a historical mistake, this returns not the full image configuration,
|
// Note that due to a historical mistake, this returns not the full image configuration,
|
||||||
// but just the container runtime configuration. You should use GetFullConfig instead.
|
// but just the container runtime configuration. You should use GetFullConfig instead.
|
||||||
func (h *proxyHandler) GetConfig(args []interface{}) (replyBuf, error) {
|
func (h *proxyHandler) GetConfig(args []any) (replyBuf, error) {
|
||||||
h.lock.Lock()
|
h.lock.Lock()
|
||||||
defer h.lock.Unlock()
|
defer h.lock.Unlock()
|
||||||
|
|
||||||
@ -562,7 +562,7 @@ func (h *proxyHandler) GetConfig(args []interface{}) (replyBuf, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetBlob fetches a blob, performing digest verification.
|
// GetBlob fetches a blob, performing digest verification.
|
||||||
func (h *proxyHandler) GetBlob(args []interface{}) (replyBuf, error) {
|
func (h *proxyHandler) GetBlob(args []any) (replyBuf, error) {
|
||||||
h.lock.Lock()
|
h.lock.Lock()
|
||||||
defer h.lock.Unlock()
|
defer h.lock.Unlock()
|
||||||
|
|
||||||
@ -632,7 +632,7 @@ func (h *proxyHandler) GetBlob(args []interface{}) (replyBuf, error) {
|
|||||||
// This needs to be called since the data returned by GetManifest() does not allow to correctly
|
// This needs to be called since the data returned by GetManifest() does not allow to correctly
|
||||||
// calling GetBlob() for the containers-storage: transport (which doesn’t store the original compressed
|
// calling GetBlob() for the containers-storage: transport (which doesn’t store the original compressed
|
||||||
// representations referenced in the manifest).
|
// representations referenced in the manifest).
|
||||||
func (h *proxyHandler) GetLayerInfo(args []interface{}) (replyBuf, error) {
|
func (h *proxyHandler) GetLayerInfo(args []any) (replyBuf, error) {
|
||||||
h.lock.Lock()
|
h.lock.Lock()
|
||||||
defer h.lock.Unlock()
|
defer h.lock.Unlock()
|
||||||
|
|
||||||
@ -678,7 +678,7 @@ func (h *proxyHandler) GetLayerInfo(args []interface{}) (replyBuf, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// FinishPipe waits for the worker goroutine to finish, and closes the write side of the pipe.
|
// FinishPipe waits for the worker goroutine to finish, and closes the write side of the pipe.
|
||||||
func (h *proxyHandler) FinishPipe(args []interface{}) (replyBuf, error) {
|
func (h *proxyHandler) FinishPipe(args []any) (replyBuf, error) {
|
||||||
h.lock.Lock()
|
h.lock.Lock()
|
||||||
defer h.lock.Unlock()
|
defer h.lock.Unlock()
|
||||||
|
|
||||||
|
@ -607,12 +607,12 @@ func assertDirImagesAreEqual(c *check.C, dir1, dir2 string) {
|
|||||||
// Check whether schema1 dir: images in dir1 and dir2 are equal, ignoring schema1 signatures and the embedded path/tag values, which should have the expected values.
|
// Check whether schema1 dir: images in dir1 and dir2 are equal, ignoring schema1 signatures and the embedded path/tag values, which should have the expected values.
|
||||||
func assertSchema1DirImagesAreEqualExceptNames(c *check.C, dir1, ref1, dir2, ref2 string) {
|
func assertSchema1DirImagesAreEqualExceptNames(c *check.C, dir1, ref1, dir2, ref2 string) {
|
||||||
// The manifests may have different JWS signatures and names; so, unmarshal and delete these elements.
|
// The manifests may have different JWS signatures and names; so, unmarshal and delete these elements.
|
||||||
manifests := []map[string]interface{}{}
|
manifests := []map[string]any{}
|
||||||
for dir, ref := range map[string]string{dir1: ref1, dir2: ref2} {
|
for dir, ref := range map[string]string{dir1: ref1, dir2: ref2} {
|
||||||
manifestPath := filepath.Join(dir, "manifest.json")
|
manifestPath := filepath.Join(dir, "manifest.json")
|
||||||
m, err := os.ReadFile(manifestPath)
|
m, err := os.ReadFile(manifestPath)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
data := map[string]interface{}{}
|
data := map[string]any{}
|
||||||
err = json.Unmarshal(m, &data)
|
err = json.Unmarshal(m, &data)
|
||||||
c.Assert(err, check.IsNil)
|
c.Assert(err, check.IsNil)
|
||||||
c.Assert(data["schemaVersion"], check.Equals, float64(1))
|
c.Assert(data["schemaVersion"], check.Equals, float64(1))
|
||||||
|
@ -32,7 +32,7 @@ type request struct {
|
|||||||
// Method is the name of the function
|
// Method is the name of the function
|
||||||
Method string `json:"method"`
|
Method string `json:"method"`
|
||||||
// Args is the arguments (parsed inside the function)
|
// Args is the arguments (parsed inside the function)
|
||||||
Args []interface{} `json:"args"`
|
Args []any `json:"args"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// reply is copied from proxy.go
|
// reply is copied from proxy.go
|
||||||
@ -40,7 +40,7 @@ type reply struct {
|
|||||||
// Success is true if and only if the call succeeded.
|
// Success is true if and only if the call succeeded.
|
||||||
Success bool `json:"success"`
|
Success bool `json:"success"`
|
||||||
// Value is an arbitrary value (or values, as array/map) returned from the call.
|
// Value is an arbitrary value (or values, as array/map) returned from the call.
|
||||||
Value interface{} `json:"value"`
|
Value any `json:"value"`
|
||||||
// PipeID is an index into open pipes, and should be passed to FinishPipe
|
// PipeID is an index into open pipes, and should be passed to FinishPipe
|
||||||
PipeID uint32 `json:"pipeid"`
|
PipeID uint32 `json:"pipeid"`
|
||||||
// Error should be non-empty if Success == false
|
// Error should be non-empty if Success == false
|
||||||
@ -60,7 +60,7 @@ type pipefd struct {
|
|||||||
fd *os.File
|
fd *os.File
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *proxy) call(method string, args []interface{}) (rval interface{}, fd *pipefd, err error) {
|
func (p *proxy) call(method string, args []any) (rval any, fd *pipefd, err error) {
|
||||||
req := request{
|
req := request{
|
||||||
Method: method,
|
Method: method,
|
||||||
Args: args,
|
Args: args,
|
||||||
@ -122,7 +122,7 @@ func (p *proxy) call(method string, args []interface{}) (rval interface{}, fd *p
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *proxy) callNoFd(method string, args []interface{}) (rval interface{}, err error) {
|
func (p *proxy) callNoFd(method string, args []any) (rval any, err error) {
|
||||||
var fd *pipefd
|
var fd *pipefd
|
||||||
rval, fd, err = p.call(method, args)
|
rval, fd, err = p.call(method, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -135,7 +135,7 @@ func (p *proxy) callNoFd(method string, args []interface{}) (rval interface{}, e
|
|||||||
return rval, nil
|
return rval, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *proxy) callReadAllBytes(method string, args []interface{}) (rval interface{}, buf []byte, err error) {
|
func (p *proxy) callReadAllBytes(method string, args []any) (rval any, buf []byte, err error) {
|
||||||
var fd *pipefd
|
var fd *pipefd
|
||||||
rval, fd, err = p.call(method, args)
|
rval, fd, err = p.call(method, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -153,7 +153,7 @@ func (p *proxy) callReadAllBytes(method string, args []interface{}) (rval interf
|
|||||||
err: err,
|
err: err,
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
_, err = p.callNoFd("FinishPipe", []interface{}{fd.id})
|
_, err = p.callNoFd("FinishPipe", []any{fd.id})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ type byteFetch struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runTestGetManifestAndConfig(p *proxy, img string) error {
|
func runTestGetManifestAndConfig(p *proxy, img string) error {
|
||||||
v, err := p.callNoFd("OpenImage", []interface{}{knownNotManifestListedImage_x8664})
|
v, err := p.callNoFd("OpenImage", []any{knownNotManifestListedImage_x8664})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -248,7 +248,7 @@ func runTestGetManifestAndConfig(p *proxy, img string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Also verify the optional path
|
// Also verify the optional path
|
||||||
v, err = p.callNoFd("OpenImageOptional", []interface{}{knownNotManifestListedImage_x8664})
|
v, err = p.callNoFd("OpenImageOptional", []any{knownNotManifestListedImage_x8664})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -262,12 +262,12 @@ func runTestGetManifestAndConfig(p *proxy, img string) error {
|
|||||||
return fmt.Errorf("got zero from expected image")
|
return fmt.Errorf("got zero from expected image")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = p.callNoFd("CloseImage", []interface{}{imgid2})
|
_, err = p.callNoFd("CloseImage", []any{imgid2})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, manifestBytes, err := p.callReadAllBytes("GetManifest", []interface{}{imgid})
|
_, manifestBytes, err := p.callReadAllBytes("GetManifest", []any{imgid})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -276,7 +276,7 @@ func runTestGetManifestAndConfig(p *proxy, img string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, configBytes, err := p.callReadAllBytes("GetFullConfig", []interface{}{imgid})
|
_, configBytes, err := p.callReadAllBytes("GetFullConfig", []any{imgid})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -295,7 +295,7 @@ func runTestGetManifestAndConfig(p *proxy, img string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Also test this legacy interface
|
// Also test this legacy interface
|
||||||
_, ctrconfigBytes, err := p.callReadAllBytes("GetConfig", []interface{}{imgid})
|
_, ctrconfigBytes, err := p.callReadAllBytes("GetConfig", []any{imgid})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -310,7 +310,7 @@ func runTestGetManifestAndConfig(p *proxy, img string) error {
|
|||||||
return fmt.Errorf("No CMD or ENTRYPOINT set")
|
return fmt.Errorf("No CMD or ENTRYPOINT set")
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = p.callNoFd("CloseImage", []interface{}{imgid})
|
_, err = p.callNoFd("CloseImage", []any{imgid})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -319,7 +319,7 @@ func runTestGetManifestAndConfig(p *proxy, img string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runTestOpenImageOptionalNotFound(p *proxy, img string) error {
|
func runTestOpenImageOptionalNotFound(p *proxy, img string) error {
|
||||||
v, err := p.callNoFd("OpenImageOptional", []interface{}{img})
|
v, err := p.callNoFd("OpenImageOptional", []any{img})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user