mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-01 00:23:56 +08:00 
			
		
		
		
	vendor: update buildkit with typed errors support
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
		
							
								
								
									
										151
									
								
								vendor/github.com/Microsoft/go-winio/vhd/vhd.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										151
									
								
								vendor/github.com/Microsoft/go-winio/vhd/vhd.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,151 @@ | ||||
| // +build windows | ||||
|  | ||||
| package vhd | ||||
|  | ||||
| import "syscall" | ||||
|  | ||||
| //go:generate go run mksyscall_windows.go -output zvhd.go vhd.go | ||||
|  | ||||
| //sys createVirtualDisk(virtualStorageType *virtualStorageType, path string, virtualDiskAccessMask uint32, securityDescriptor *uintptr, flags uint32, providerSpecificFlags uint32, parameters *createVirtualDiskParameters, o *syscall.Overlapped, handle *syscall.Handle) (err error) [failretval != 0] = VirtDisk.CreateVirtualDisk | ||||
| //sys openVirtualDisk(virtualStorageType *virtualStorageType, path string, virtualDiskAccessMask uint32, flags uint32, parameters *openVirtualDiskParameters, handle *syscall.Handle) (err error) [failretval != 0] = VirtDisk.OpenVirtualDisk | ||||
| //sys detachVirtualDisk(handle syscall.Handle, flags uint32, providerSpecificFlags uint32) (err error) [failretval != 0] = VirtDisk.DetachVirtualDisk | ||||
|  | ||||
| type virtualStorageType struct { | ||||
| 	DeviceID uint32 | ||||
| 	VendorID [16]byte | ||||
| } | ||||
|  | ||||
| type ( | ||||
| 	createVirtualDiskFlag uint32 | ||||
| 	VirtualDiskAccessMask uint32 | ||||
| 	VirtualDiskFlag       uint32 | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| 	// Flags for creating a VHD (not exported) | ||||
| 	createVirtualDiskFlagNone                        createVirtualDiskFlag = 0 | ||||
| 	createVirtualDiskFlagFullPhysicalAllocation      createVirtualDiskFlag = 1 | ||||
| 	createVirtualDiskFlagPreventWritesToSourceDisk   createVirtualDiskFlag = 2 | ||||
| 	createVirtualDiskFlagDoNotCopyMetadataFromParent createVirtualDiskFlag = 4 | ||||
|  | ||||
| 	// Access Mask for opening a VHD | ||||
| 	VirtualDiskAccessNone     VirtualDiskAccessMask = 0 | ||||
| 	VirtualDiskAccessAttachRO VirtualDiskAccessMask = 65536 | ||||
| 	VirtualDiskAccessAttachRW VirtualDiskAccessMask = 131072 | ||||
| 	VirtualDiskAccessDetach   VirtualDiskAccessMask = 262144 | ||||
| 	VirtualDiskAccessGetInfo  VirtualDiskAccessMask = 524288 | ||||
| 	VirtualDiskAccessCreate   VirtualDiskAccessMask = 1048576 | ||||
| 	VirtualDiskAccessMetaOps  VirtualDiskAccessMask = 2097152 | ||||
| 	VirtualDiskAccessRead     VirtualDiskAccessMask = 851968 | ||||
| 	VirtualDiskAccessAll      VirtualDiskAccessMask = 4128768 | ||||
| 	VirtualDiskAccessWritable VirtualDiskAccessMask = 3276800 | ||||
|  | ||||
| 	// Flags for opening a VHD | ||||
| 	OpenVirtualDiskFlagNone                        VirtualDiskFlag = 0 | ||||
| 	OpenVirtualDiskFlagNoParents                   VirtualDiskFlag = 0x1 | ||||
| 	OpenVirtualDiskFlagBlankFile                   VirtualDiskFlag = 0x2 | ||||
| 	OpenVirtualDiskFlagBootDrive                   VirtualDiskFlag = 0x4 | ||||
| 	OpenVirtualDiskFlagCachedIO                    VirtualDiskFlag = 0x8 | ||||
| 	OpenVirtualDiskFlagCustomDiffChain             VirtualDiskFlag = 0x10 | ||||
| 	OpenVirtualDiskFlagParentCachedIO              VirtualDiskFlag = 0x20 | ||||
| 	OpenVirtualDiskFlagVhdSetFileOnly              VirtualDiskFlag = 0x40 | ||||
| 	OpenVirtualDiskFlagIgnoreRelativeParentLocator VirtualDiskFlag = 0x80 | ||||
| 	OpenVirtualDiskFlagNoWriteHardening            VirtualDiskFlag = 0x100 | ||||
| ) | ||||
|  | ||||
| type createVersion2 struct { | ||||
| 	UniqueID                 [16]byte // GUID | ||||
| 	MaximumSize              uint64 | ||||
| 	BlockSizeInBytes         uint32 | ||||
| 	SectorSizeInBytes        uint32 | ||||
| 	ParentPath               *uint16 // string | ||||
| 	SourcePath               *uint16 // string | ||||
| 	OpenFlags                uint32 | ||||
| 	ParentVirtualStorageType virtualStorageType | ||||
| 	SourceVirtualStorageType virtualStorageType | ||||
| 	ResiliencyGUID           [16]byte // GUID | ||||
| } | ||||
|  | ||||
| type createVirtualDiskParameters struct { | ||||
| 	Version  uint32 // Must always be set to 2 | ||||
| 	Version2 createVersion2 | ||||
| } | ||||
|  | ||||
| type openVersion2 struct { | ||||
| 	GetInfoOnly    int32    // bool but 4-byte aligned | ||||
| 	ReadOnly       int32    // bool but 4-byte aligned | ||||
| 	ResiliencyGUID [16]byte // GUID | ||||
| } | ||||
|  | ||||
| type openVirtualDiskParameters struct { | ||||
| 	Version  uint32 // Must always be set to 2 | ||||
| 	Version2 openVersion2 | ||||
| } | ||||
|  | ||||
| // CreateVhdx will create a simple vhdx file at the given path using default values. | ||||
| func CreateVhdx(path string, maxSizeInGb, blockSizeInMb uint32) error { | ||||
| 	var ( | ||||
| 		defaultType virtualStorageType | ||||
| 		handle      syscall.Handle | ||||
| 	) | ||||
|  | ||||
| 	parameters := createVirtualDiskParameters{ | ||||
| 		Version: 2, | ||||
| 		Version2: createVersion2{ | ||||
| 			MaximumSize:      uint64(maxSizeInGb) * 1024 * 1024 * 1024, | ||||
| 			BlockSizeInBytes: blockSizeInMb * 1024 * 1024, | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	if err := createVirtualDisk( | ||||
| 		&defaultType, | ||||
| 		path, | ||||
| 		uint32(VirtualDiskAccessNone), | ||||
| 		nil, | ||||
| 		uint32(createVirtualDiskFlagNone), | ||||
| 		0, | ||||
| 		¶meters, | ||||
| 		nil, | ||||
| 		&handle); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	if err := syscall.CloseHandle(handle); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // DetachVhd detaches a mounted container layer vhd found at `path`. | ||||
| func DetachVhd(path string) error { | ||||
| 	handle, err := OpenVirtualDisk( | ||||
| 		path, | ||||
| 		VirtualDiskAccessNone, | ||||
| 		OpenVirtualDiskFlagCachedIO|OpenVirtualDiskFlagIgnoreRelativeParentLocator) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer syscall.CloseHandle(handle) | ||||
| 	return detachVirtualDisk(handle, 0, 0) | ||||
| } | ||||
|  | ||||
| // OpenVirtualDisk obtains a handle to a VHD opened with supplied access mask and flags. | ||||
| func OpenVirtualDisk(path string, accessMask VirtualDiskAccessMask, flag VirtualDiskFlag) (syscall.Handle, error) { | ||||
| 	var ( | ||||
| 		defaultType virtualStorageType | ||||
| 		handle      syscall.Handle | ||||
| 	) | ||||
| 	parameters := openVirtualDiskParameters{Version: 2} | ||||
| 	if err := openVirtualDisk( | ||||
| 		&defaultType, | ||||
| 		path, | ||||
| 		uint32(accessMask), | ||||
| 		uint32(flag), | ||||
| 		¶meters, | ||||
| 		&handle); err != nil { | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	return handle, nil | ||||
| } | ||||
							
								
								
									
										99
									
								
								vendor/github.com/Microsoft/go-winio/vhd/zvhd.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								vendor/github.com/Microsoft/go-winio/vhd/zvhd.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,99 @@ | ||||
| // MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT | ||||
|  | ||||
| package vhd | ||||
|  | ||||
| import ( | ||||
| 	"syscall" | ||||
| 	"unsafe" | ||||
|  | ||||
| 	"golang.org/x/sys/windows" | ||||
| ) | ||||
|  | ||||
| var _ unsafe.Pointer | ||||
|  | ||||
| // Do the interface allocations only once for common | ||||
| // Errno values. | ||||
| const ( | ||||
| 	errnoERROR_IO_PENDING = 997 | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) | ||||
| ) | ||||
|  | ||||
| // errnoErr returns common boxed Errno values, to prevent | ||||
| // allocations at runtime. | ||||
| func errnoErr(e syscall.Errno) error { | ||||
| 	switch e { | ||||
| 	case 0: | ||||
| 		return nil | ||||
| 	case errnoERROR_IO_PENDING: | ||||
| 		return errERROR_IO_PENDING | ||||
| 	} | ||||
| 	// TODO: add more here, after collecting data on the common | ||||
| 	// error values see on Windows. (perhaps when running | ||||
| 	// all.bat?) | ||||
| 	return e | ||||
| } | ||||
|  | ||||
| var ( | ||||
| 	modVirtDisk = windows.NewLazySystemDLL("VirtDisk.dll") | ||||
|  | ||||
| 	procCreateVirtualDisk = modVirtDisk.NewProc("CreateVirtualDisk") | ||||
| 	procOpenVirtualDisk   = modVirtDisk.NewProc("OpenVirtualDisk") | ||||
| 	procDetachVirtualDisk = modVirtDisk.NewProc("DetachVirtualDisk") | ||||
| ) | ||||
|  | ||||
| func createVirtualDisk(virtualStorageType *virtualStorageType, path string, virtualDiskAccessMask uint32, securityDescriptor *uintptr, flags uint32, providerSpecificFlags uint32, parameters *createVirtualDiskParameters, o *syscall.Overlapped, handle *syscall.Handle) (err error) { | ||||
| 	var _p0 *uint16 | ||||
| 	_p0, err = syscall.UTF16PtrFromString(path) | ||||
| 	if err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	return _createVirtualDisk(virtualStorageType, _p0, virtualDiskAccessMask, securityDescriptor, flags, providerSpecificFlags, parameters, o, handle) | ||||
| } | ||||
|  | ||||
| func _createVirtualDisk(virtualStorageType *virtualStorageType, path *uint16, virtualDiskAccessMask uint32, securityDescriptor *uintptr, flags uint32, providerSpecificFlags uint32, parameters *createVirtualDiskParameters, o *syscall.Overlapped, handle *syscall.Handle) (err error) { | ||||
| 	r1, _, e1 := syscall.Syscall9(procCreateVirtualDisk.Addr(), 9, uintptr(unsafe.Pointer(virtualStorageType)), uintptr(unsafe.Pointer(path)), uintptr(virtualDiskAccessMask), uintptr(unsafe.Pointer(securityDescriptor)), uintptr(flags), uintptr(providerSpecificFlags), uintptr(unsafe.Pointer(parameters)), uintptr(unsafe.Pointer(o)), uintptr(unsafe.Pointer(handle))) | ||||
| 	if r1 != 0 { | ||||
| 		if e1 != 0 { | ||||
| 			err = errnoErr(e1) | ||||
| 		} else { | ||||
| 			err = syscall.EINVAL | ||||
| 		} | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| func openVirtualDisk(virtualStorageType *virtualStorageType, path string, virtualDiskAccessMask uint32, flags uint32, parameters *openVirtualDiskParameters, handle *syscall.Handle) (err error) { | ||||
| 	var _p0 *uint16 | ||||
| 	_p0, err = syscall.UTF16PtrFromString(path) | ||||
| 	if err != nil { | ||||
| 		return | ||||
| 	} | ||||
| 	return _openVirtualDisk(virtualStorageType, _p0, virtualDiskAccessMask, flags, parameters, handle) | ||||
| } | ||||
|  | ||||
| func _openVirtualDisk(virtualStorageType *virtualStorageType, path *uint16, virtualDiskAccessMask uint32, flags uint32, parameters *openVirtualDiskParameters, handle *syscall.Handle) (err error) { | ||||
| 	r1, _, e1 := syscall.Syscall6(procOpenVirtualDisk.Addr(), 6, uintptr(unsafe.Pointer(virtualStorageType)), uintptr(unsafe.Pointer(path)), uintptr(virtualDiskAccessMask), uintptr(flags), uintptr(unsafe.Pointer(parameters)), uintptr(unsafe.Pointer(handle))) | ||||
| 	if r1 != 0 { | ||||
| 		if e1 != 0 { | ||||
| 			err = errnoErr(e1) | ||||
| 		} else { | ||||
| 			err = syscall.EINVAL | ||||
| 		} | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
|  | ||||
| func detachVirtualDisk(handle syscall.Handle, flags uint32, providerSpecificFlags uint32) (err error) { | ||||
| 	r1, _, e1 := syscall.Syscall(procDetachVirtualDisk.Addr(), 3, uintptr(handle), uintptr(flags), uintptr(providerSpecificFlags)) | ||||
| 	if r1 != 0 { | ||||
| 		if e1 != 0 { | ||||
| 			err = errnoErr(e1) | ||||
| 		} else { | ||||
| 			err = syscall.EINVAL | ||||
| 		} | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
							
								
								
									
										3
									
								
								vendor/github.com/Microsoft/hcsshim/CODEOWNERS
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								vendor/github.com/Microsoft/hcsshim/CODEOWNERS
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| * @microsoft/containerplat | ||||
|  | ||||
| /hcn/* @nagiesek | ||||
							
								
								
									
										7
									
								
								vendor/github.com/Microsoft/hcsshim/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								vendor/github.com/Microsoft/hcsshim/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| [](https://ci.appveyor.com/project/WindowsVirtualization/hcsshim/branch/master) | ||||
|  | ||||
| This package contains the Golang interface for using the Windows [Host Compute Service](https://blogs.technet.microsoft.com/virtualization/2017/01/27/introducing-the-host-compute-service-hcs/) (HCS) to launch and manage [Windows Containers](https://docs.microsoft.com/en-us/virtualization/windowscontainers/about/). It also contains other helpers and functions for managing Windows Containers such as the Golang interface for the Host Network Service (HNS). | ||||
| This package contains the Golang interface for using the Windows [Host Compute Service](https://techcommunity.microsoft.com/t5/containers/introducing-the-host-compute-service-hcs/ba-p/382332) (HCS) to launch and manage [Windows Containers](https://docs.microsoft.com/en-us/virtualization/windowscontainers/about/). It also contains other helpers and functions for managing Windows Containers such as the Golang interface for the Host Network Service (HNS). | ||||
|  | ||||
| It is primarily used in the [Moby Project](https://github.com/moby/moby), but it can be freely used by other projects as well. | ||||
|  | ||||
| @@ -16,6 +16,11 @@ When you submit a pull request, a CLA-bot will automatically determine whether y | ||||
| a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions | ||||
| provided by the bot. You will only need to do this once across all repos using our CLA. | ||||
|  | ||||
| We also ask that contributors [sign their commits](https://git-scm.com/docs/git-commit) using `git commit -s` or `git commit --signoff` to certify they either authored the work themselves or otherwise have permission to use it in this project.  | ||||
|  | ||||
|  | ||||
| ## Code of Conduct | ||||
|  | ||||
| This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). | ||||
| For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or | ||||
| contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. | ||||
|   | ||||
							
								
								
									
										20
									
								
								vendor/github.com/Microsoft/hcsshim/appveyor.yml
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								vendor/github.com/Microsoft/hcsshim/appveyor.yml
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -6,7 +6,7 @@ clone_folder: c:\gopath\src\github.com\Microsoft\hcsshim | ||||
|  | ||||
| environment: | ||||
|   GOPATH: c:\gopath | ||||
|   PATH: C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;%GOPATH%\bin;C:\gometalinter-2.0.12-windows-amd64;%PATH% | ||||
|   PATH: "%GOPATH%\\bin;C:\\gometalinter-2.0.12-windows-amd64;%PATH%" | ||||
|  | ||||
| stack: go 1.13.4 | ||||
|  | ||||
| @@ -22,10 +22,12 @@ build_script: | ||||
|   - go build ./internal/tools/uvmboot | ||||
|   - go build ./internal/tools/zapdir | ||||
|   - go test -v ./... -tags admin | ||||
|   - go test -c ./test/containerd-shim-runhcs-v1/ -tags functional | ||||
|   - go test -c ./test/cri-containerd/ -tags functional | ||||
|   - go test -c ./test/functional/ -tags functional | ||||
|   - go test -c ./test/runhcs/ -tags functional | ||||
|   - cd test | ||||
|   - go test -v ./internal -tags admin | ||||
|   - go test -c ./containerd-shim-runhcs-v1/ -tags functional | ||||
|   - go test -c ./cri-containerd/ -tags functional | ||||
|   - go test -c ./functional/ -tags functional | ||||
|   - go test -c ./runhcs/ -tags functional | ||||
|  | ||||
| artifacts: | ||||
|   - path: 'containerd-shim-runhcs-v1.exe' | ||||
| @@ -35,7 +37,7 @@ artifacts: | ||||
|   - path: 'grantvmgroupaccess.exe'   | ||||
|   - path: 'uvmboot.exe' | ||||
|   - path: 'zapdir.exe' | ||||
|   - path: 'containerd-shim-runhcs-v1.test.exe' | ||||
|   - path: 'cri-containerd.test.exe' | ||||
|   - path: 'functional.test.exe' | ||||
|   - path: 'runhcs.test.exe' | ||||
|   - path: './test/containerd-shim-runhcs-v1.test.exe' | ||||
|   - path: './test/cri-containerd.test.exe' | ||||
|   - path: './test/functional.test.exe' | ||||
|   - path: './test/runhcs.test.exe' | ||||
|   | ||||
							
								
								
									
										28
									
								
								vendor/github.com/Microsoft/hcsshim/go.mod
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										28
									
								
								vendor/github.com/Microsoft/hcsshim/go.mod
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -4,34 +4,32 @@ go 1.13 | ||||
|  | ||||
| require ( | ||||
| 	github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5 | ||||
| 	github.com/blang/semver v3.1.0+incompatible // indirect | ||||
| 	github.com/containerd/cgroups v0.0.0-20190919134610-bf292b21730f | ||||
| 	github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1 | ||||
| 	github.com/containerd/containerd v1.3.0-beta.2.0.20190828155532-0293cbd26c69 | ||||
| 	github.com/containerd/containerd v1.3.2 | ||||
| 	github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc // indirect | ||||
| 	github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448 // indirect | ||||
| 	github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3 | ||||
| 	github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de | ||||
| 	github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd | ||||
| 	github.com/gogo/protobuf v1.2.1 | ||||
| 	github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce // indirect | ||||
| 	github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874 // indirect | ||||
| 	github.com/gogo/protobuf v1.3.1 | ||||
| 	github.com/golang/protobuf v1.3.2 // indirect | ||||
| 	github.com/kr/pretty v0.1.0 // indirect | ||||
| 	github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2 // indirect | ||||
| 	github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f // indirect | ||||
| 	github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700 | ||||
| 	github.com/opencontainers/runtime-tools v0.0.0-20181011054405-1d69bd0f9c39 | ||||
| 	github.com/pkg/errors v0.8.1 | ||||
| 	github.com/prometheus/procfs v0.0.5 // indirect | ||||
| 	github.com/sirupsen/logrus v1.4.1 | ||||
| 	github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8 // indirect | ||||
| 	github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7 // indirect | ||||
| 	github.com/sirupsen/logrus v1.4.2 | ||||
| 	github.com/stretchr/testify v1.4.0 // indirect | ||||
| 	github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5 | ||||
| 	github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect | ||||
| 	github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect | ||||
| 	github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f // indirect | ||||
| 	go.opencensus.io v0.22.0 | ||||
| 	golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 | ||||
| 	golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 // indirect | ||||
| 	golang.org/x/sync v0.0.0-20190423024810-112230192c58 | ||||
| 	golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3 | ||||
| 	google.golang.org/grpc v1.20.1 | ||||
| 	google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873 // indirect | ||||
| 	google.golang.org/grpc v1.23.1 | ||||
| 	gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect | ||||
| 	gopkg.in/yaml.v2 v2.2.8 // indirect | ||||
| 	gotest.tools v2.2.0+incompatible // indirect | ||||
| 	k8s.io/kubernetes v1.13.0 | ||||
| ) | ||||
|   | ||||
							
								
								
									
										64
									
								
								vendor/github.com/Microsoft/hcsshim/go.sum
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										64
									
								
								vendor/github.com/Microsoft/hcsshim/go.sum
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,16 +1,15 @@ | ||||
| cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= | ||||
| github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= | ||||
| github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= | ||||
| github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5 h1:ygIc8M6trr62pF5DucadTWGdEB4mEyvzi0e2nbcmcyA= | ||||
| github.com/Microsoft/go-winio v0.4.15-0.20190919025122-fc70bd9a86b5/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw= | ||||
| github.com/blang/semver v3.1.0+incompatible h1:7hqmJYuaEK3qwVjWubYiht3j93YI0WQBuysxHIfUriU= | ||||
| github.com/blang/semver v3.1.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= | ||||
| github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= | ||||
| github.com/containerd/cgroups v0.0.0-20190919134610-bf292b21730f h1:tSNMc+rJDfmYntojat8lljbt1mgKNpTxUZJsSzJ9Y1s= | ||||
| github.com/containerd/cgroups v0.0.0-20190919134610-bf292b21730f/go.mod h1:OApqhQ4XNSNC13gXIwDjhOQxjWa/NxkwZXJ1EvqT0ko= | ||||
| github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1 h1:uict5mhHFTzKLUCufdSLym7z/J0CbBJT59lYbP9wtbg= | ||||
| github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw= | ||||
| github.com/containerd/containerd v1.3.0-beta.2.0.20190828155532-0293cbd26c69 h1:rG1clvJbgsUcmb50J82YUJhUMopWNtZvyMZjb+4fqGw= | ||||
| github.com/containerd/containerd v1.3.0-beta.2.0.20190828155532-0293cbd26c69/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= | ||||
| github.com/containerd/containerd v1.3.2 h1:ForxmXkA6tPIvffbrDAcPUIB32QgXkt2XFj+F0UxetA= | ||||
| github.com/containerd/containerd v1.3.2/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA= | ||||
| github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc h1:TP+534wVlf61smEIq1nwLLAjQVEK2EADoW3CX9AuT+8= | ||||
| github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= | ||||
| github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448 h1:PUD50EuOMkXVcpBIA/R95d56duJR9VxhwncsFbNnxW4= | ||||
| @@ -23,6 +22,7 @@ github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd h1:JNn81o/xG+8N | ||||
| github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc= | ||||
| github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8= | ||||
| github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= | ||||
| github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= | ||||
| @@ -31,6 +31,8 @@ github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e h1:BWhy2j3IXJhjCbC68Fp | ||||
| github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= | ||||
| github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= | ||||
| github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= | ||||
| github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= | ||||
| github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= | ||||
| github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= | ||||
| github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= | ||||
| github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= | ||||
| @@ -38,47 +40,47 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM | ||||
| github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= | ||||
| github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= | ||||
| github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= | ||||
| github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= | ||||
| github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= | ||||
| github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= | ||||
| github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= | ||||
| github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= | ||||
| github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce h1:prjrVgOk2Yg6w+PflHoszQNLTUh4kaByUcEWM/9uin4= | ||||
| github.com/hashicorp/errwrap v0.0.0-20141028054710-7554cd9344ce/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= | ||||
| github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874 h1:cAv7ZbSmyb1wjn6T4TIiyFCkpcfgpbcNNC3bM2srLaI= | ||||
| github.com/hashicorp/go-multierror v0.0.0-20161216184304-ed905158d874/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I= | ||||
| github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= | ||||
| github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= | ||||
| github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= | ||||
| github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= | ||||
| github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= | ||||
| github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= | ||||
| github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= | ||||
| github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= | ||||
| github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= | ||||
| github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= | ||||
| github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= | ||||
| github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= | ||||
| github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2 h1:QhPf3A2AZW3tTGvHPg0TA+CR3oHbVLlXUhlghqISp1I= | ||||
| github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= | ||||
| github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f h1:a969LJ4IQFwRHYqonHtUDMSh9i54WcKggeEkQ3fZMl4= | ||||
| github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= | ||||
| github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700 h1:eNUVfm/RFLIi1G7flU5/ZRTHvd4kcVuzfRnL6OFlzCI= | ||||
| github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= | ||||
| github.com/opencontainers/runtime-tools v0.0.0-20181011054405-1d69bd0f9c39 h1:H7DMc6FAjgwZZi8BRqjrAAHWoqEr5e5L6pS4V0ezet4= | ||||
| github.com/opencontainers/runtime-tools v0.0.0-20181011054405-1d69bd0f9c39/go.mod h1:r3f7wjNzSs2extwzU3Y+6pKfobzPh+kKFJ3ofN+3nfs= | ||||
| github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= | ||||
| github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||||
| github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||
| github.com/prometheus/procfs v0.0.5 h1:3+auTFlqw+ZaQYJARz6ArODtkaIwtvBTx3N2NehQlL8= | ||||
| github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= | ||||
| github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7 h1:hhvfGDVThBnd4kYisSFmYuHYeUhglxcwag7FhVPH9zM= | ||||
| github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= | ||||
| github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k= | ||||
| github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= | ||||
| github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= | ||||
| github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= | ||||
| github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||
| github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||
| github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= | ||||
| github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | ||||
| github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8 h1:zLV6q4e8Jv9EHjNg/iHfzwDkCve6Ua5jCygptrtXHvI= | ||||
| github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= | ||||
| github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= | ||||
| github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= | ||||
| github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5 h1:MCfT24H3f//U5+UCrZp1/riVO3B50BovxtDiNn0XKkk= | ||||
| github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= | ||||
| github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= | ||||
| github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= | ||||
| github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= | ||||
| github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= | ||||
| github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f h1:mvXjJIHRZyhNuGassLTcXTwjiWq7NmjdavZsUnmFybQ= | ||||
| github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= | ||||
| go.opencensus.io v0.22.0 h1:C9hSCOW830chIVkdja34wa6Ky+IzWllkUinR+BtRZd4= | ||||
| go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= | ||||
| golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||||
| @@ -93,15 +95,19 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJV | ||||
| golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||||
| golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09 h1:KaQtG+aDELoNmXYas3TVkGNYRuq8JQ1aa7LJt8EXVyo= | ||||
| golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||||
| golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 h1:rjwSpXsdiK0dV8/Naq3kAw9ymfAeJIyd0upUIElB+lI= | ||||
| golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||||
| golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= | ||||
| golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI= | ||||
| golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= | ||||
| golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||||
| golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||||
| golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||||
| golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20190514135907-3a4b5fb9f71f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3 h1:7TYNF4UdlohbFwpNH04CoPMp1cHUZgO1Ebq5r2hIjfo= | ||||
| @@ -112,20 +118,32 @@ golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= | ||||
| golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= | ||||
| golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||||
| golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||||
| golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||||
| golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||||
| golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= | ||||
| golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= | ||||
| golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= | ||||
| google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= | ||||
| google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= | ||||
| google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= | ||||
| google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= | ||||
| google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb h1:i1Ppqkc3WQXikh8bXiwHqAN5Rv3/qDCcRk0/Otx73BY= | ||||
| google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= | ||||
| google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873 h1:nfPFGzJkUDX6uBmpN/pSw7MbOAWegH5QDQuoXFHedLg= | ||||
| google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= | ||||
| google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= | ||||
| google.golang.org/grpc v1.20.1 h1:Hz2g2wirWK7H0qIIhGIqRGTuMwTE8HEKFnDZZ7lm9NU= | ||||
| google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= | ||||
| google.golang.org/grpc v1.23.1 h1:q4XQuHFC6I28BKZpo6IYyb3mNO+l7lSOxRuYTCiDfXk= | ||||
| google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= | ||||
| gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= | ||||
| gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||||
| gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= | ||||
| gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||||
| gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= | ||||
| gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= | ||||
| honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= | ||||
| k8s.io/kubernetes v1.13.0 h1:qTfB+u5M92k2fCCCVP2iuhgwwSOv1EkAkvQY1tQODD8= | ||||
| k8s.io/kubernetes v1.13.0/go.mod h1:ocZa8+6APFNC2tX1DZASIbocyYT5jHzqFVsY5aoB7Jk= | ||||
| honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= | ||||
|   | ||||
							
								
								
									
										3
									
								
								vendor/github.com/Microsoft/hcsshim/hnspolicy.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								vendor/github.com/Microsoft/hcsshim/hnspolicy.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -21,8 +21,11 @@ const ( | ||||
| 	OutboundNat          = hns.OutboundNat | ||||
| 	ExternalLoadBalancer = hns.ExternalLoadBalancer | ||||
| 	Route                = hns.Route | ||||
| 	Proxy                = hns.Proxy | ||||
| ) | ||||
|  | ||||
| type ProxyPolicy = hns.ProxyPolicy | ||||
|  | ||||
| type NatPolicy = hns.NatPolicy | ||||
|  | ||||
| type QosPolicy = hns.QosPolicy | ||||
|   | ||||
							
								
								
									
										7
									
								
								vendor/github.com/Microsoft/hcsshim/internal/hcs/cgo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								vendor/github.com/Microsoft/hcsshim/internal/hcs/cgo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,7 +0,0 @@ | ||||
| package hcs | ||||
|  | ||||
| import "C" | ||||
|  | ||||
| // This import is needed to make the library compile as CGO because HCSSHIM | ||||
| // only works with CGO due to callbacks from HCS comming back from a C thread | ||||
| // which is not supported without CGO. See https://github.com/golang/go/issues/10973 | ||||
							
								
								
									
										5
									
								
								vendor/github.com/Microsoft/hcsshim/internal/hcs/syscall.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								vendor/github.com/Microsoft/hcsshim/internal/hcs/syscall.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| package hcs | ||||
|  | ||||
| //go:generate go run ../../mksyscall_windows.go -output zsyscall_windows.go syscall.go | ||||
|  | ||||
| //sys hcsFormatWritableLayerVhd(handle uintptr) (hr error) = computestorage.HcsFormatWritableLayerVhd | ||||
							
								
								
									
										50
									
								
								vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										50
									
								
								vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -4,12 +4,9 @@ import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"errors" | ||||
| 	"os" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
| 	"syscall" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/Microsoft/hcsshim/internal/cow" | ||||
| 	"github.com/Microsoft/hcsshim/internal/log" | ||||
| @@ -21,27 +18,6 @@ import ( | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| // currentContainerStarts is used to limit the number of concurrent container | ||||
| // starts. | ||||
| var currentContainerStarts containerStarts | ||||
|  | ||||
| type containerStarts struct { | ||||
| 	maxParallel int | ||||
| 	inProgress  int | ||||
| 	sync.Mutex | ||||
| } | ||||
|  | ||||
| func init() { | ||||
| 	mpsS := os.Getenv("HCSSHIM_MAX_PARALLEL_START") | ||||
| 	if len(mpsS) > 0 { | ||||
| 		mpsI, err := strconv.Atoi(mpsS) | ||||
| 		if err != nil || mpsI < 0 { | ||||
| 			return | ||||
| 		} | ||||
| 		currentContainerStarts.maxParallel = mpsI | ||||
| 	} | ||||
| } | ||||
|  | ||||
| type System struct { | ||||
| 	handleLock     sync.RWMutex | ||||
| 	handle         vmcompute.HcsSystem | ||||
| @@ -215,32 +191,6 @@ func (computeSystem *System) Start(ctx context.Context) (err error) { | ||||
| 		return makeSystemError(computeSystem, operation, "", ErrAlreadyClosed, nil) | ||||
| 	} | ||||
|  | ||||
| 	// This is a very simple backoff-retry loop to limit the number | ||||
| 	// of parallel container starts if environment variable | ||||
| 	// HCSSHIM_MAX_PARALLEL_START is set to a positive integer. | ||||
| 	// It should generally only be used as a workaround to various | ||||
| 	// platform issues that exist between RS1 and RS4 as of Aug 2018 | ||||
| 	if currentContainerStarts.maxParallel > 0 { | ||||
| 		for { | ||||
| 			currentContainerStarts.Lock() | ||||
| 			if currentContainerStarts.inProgress < currentContainerStarts.maxParallel { | ||||
| 				currentContainerStarts.inProgress++ | ||||
| 				currentContainerStarts.Unlock() | ||||
| 				break | ||||
| 			} | ||||
| 			if currentContainerStarts.inProgress == currentContainerStarts.maxParallel { | ||||
| 				currentContainerStarts.Unlock() | ||||
| 				time.Sleep(100 * time.Millisecond) | ||||
| 			} | ||||
| 		} | ||||
| 		// Make sure we decrement the count when we are done. | ||||
| 		defer func() { | ||||
| 			currentContainerStarts.Lock() | ||||
| 			currentContainerStarts.inProgress-- | ||||
| 			currentContainerStarts.Unlock() | ||||
| 		}() | ||||
| 	} | ||||
|  | ||||
| 	resultJSON, err := vmcompute.HcsStartComputeSystem(ctx, computeSystem.handle, "") | ||||
| 	events, err := processAsyncHcsResult(ctx, err, resultJSON, computeSystem.callbackNumber, hcsNotificationSystemStartCompleted, &timeout.SystemStart) | ||||
| 	if err != nil { | ||||
|   | ||||
							
								
								
									
										28
									
								
								vendor/github.com/Microsoft/hcsshim/internal/hcs/utils.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										28
									
								
								vendor/github.com/Microsoft/hcsshim/internal/hcs/utils.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,10 +1,14 @@ | ||||
| package hcs | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"io" | ||||
| 	"syscall" | ||||
|  | ||||
| 	"github.com/Microsoft/go-winio" | ||||
| 	diskutil "github.com/Microsoft/go-winio/vhd" | ||||
| 	"github.com/pkg/errors" | ||||
| 	"golang.org/x/sys/windows" | ||||
| ) | ||||
|  | ||||
| // makeOpenFiles calls winio.MakeOpenFile for each handle in a slice but closes all the handles | ||||
| @@ -31,3 +35,27 @@ func makeOpenFiles(hs []syscall.Handle) (_ []io.ReadWriteCloser, err error) { | ||||
| 	} | ||||
| 	return fs, nil | ||||
| } | ||||
|  | ||||
| // creates a VHD formatted with NTFS of size `sizeGB` at the given `vhdPath`. | ||||
| func CreateNTFSVHD(ctx context.Context, vhdPath string, sizeGB uint32) (err error) { | ||||
| 	if err := diskutil.CreateVhdx(vhdPath, sizeGB, 1); err != nil { | ||||
| 		return errors.Wrap(err, "failed to create VHD") | ||||
| 	} | ||||
|  | ||||
| 	vhd, err := diskutil.OpenVirtualDisk(vhdPath, diskutil.VirtualDiskAccessNone, diskutil.OpenVirtualDiskFlagNone) | ||||
| 	if err != nil { | ||||
| 		return errors.Wrap(err, "failed to open VHD") | ||||
| 	} | ||||
| 	defer func() { | ||||
| 		err2 := windows.CloseHandle(windows.Handle(vhd)) | ||||
| 		if err == nil { | ||||
| 			err = errors.Wrap(err2, "failed to close VHD") | ||||
| 		} | ||||
| 	}() | ||||
|  | ||||
| 	if err := hcsFormatWritableLayerVhd(uintptr(vhd)); err != nil { | ||||
| 		return errors.Wrap(err, "failed to format VHD") | ||||
| 	} | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										54
									
								
								vendor/github.com/Microsoft/hcsshim/internal/hcs/zsyscall_windows.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								vendor/github.com/Microsoft/hcsshim/internal/hcs/zsyscall_windows.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,54 @@ | ||||
| // Code generated mksyscall_windows.exe DO NOT EDIT | ||||
|  | ||||
| package hcs | ||||
|  | ||||
| import ( | ||||
| 	"syscall" | ||||
| 	"unsafe" | ||||
|  | ||||
| 	"golang.org/x/sys/windows" | ||||
| ) | ||||
|  | ||||
| var _ unsafe.Pointer | ||||
|  | ||||
| // Do the interface allocations only once for common | ||||
| // Errno values. | ||||
| const ( | ||||
| 	errnoERROR_IO_PENDING = 997 | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) | ||||
| ) | ||||
|  | ||||
| // errnoErr returns common boxed Errno values, to prevent | ||||
| // allocations at runtime. | ||||
| func errnoErr(e syscall.Errno) error { | ||||
| 	switch e { | ||||
| 	case 0: | ||||
| 		return nil | ||||
| 	case errnoERROR_IO_PENDING: | ||||
| 		return errERROR_IO_PENDING | ||||
| 	} | ||||
| 	// TODO: add more here, after collecting data on the common | ||||
| 	// error values see on Windows. (perhaps when running | ||||
| 	// all.bat?) | ||||
| 	return e | ||||
| } | ||||
|  | ||||
| var ( | ||||
| 	modcomputestorage = windows.NewLazySystemDLL("computestorage.dll") | ||||
|  | ||||
| 	procHcsFormatWritableLayerVhd = modcomputestorage.NewProc("HcsFormatWritableLayerVhd") | ||||
| ) | ||||
|  | ||||
| func hcsFormatWritableLayerVhd(handle uintptr) (hr error) { | ||||
| 	r0, _, _ := syscall.Syscall(procHcsFormatWritableLayerVhd.Addr(), 1, uintptr(handle), 0, 0) | ||||
| 	if int32(r0) < 0 { | ||||
| 		if r0&0x1fff0000 == 0x00070000 { | ||||
| 			r0 &= 0xffff | ||||
| 		} | ||||
| 		hr = syscall.Errno(r0) | ||||
| 	} | ||||
| 	return | ||||
| } | ||||
							
								
								
									
										21
									
								
								vendor/github.com/Microsoft/hcsshim/internal/hns/hnsendpoint.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								vendor/github.com/Microsoft/hcsshim/internal/hns/hnsendpoint.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -173,6 +173,27 @@ func (endpoint *HNSEndpoint) ApplyACLPolicy(policies ...*ACLPolicy) error { | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ApplyProxyPolicy applies a set of Proxy Policies on the Endpoint | ||||
| func (endpoint *HNSEndpoint) ApplyProxyPolicy(policies ...*ProxyPolicy) error { | ||||
| 	operation := "ApplyProxyPolicy" | ||||
| 	title := "hcsshim::HNSEndpoint::" + operation | ||||
| 	logrus.Debugf(title+" id=%s", endpoint.Id) | ||||
|  | ||||
| 	for _, policy := range policies { | ||||
| 		if policy == nil { | ||||
| 			continue | ||||
| 		} | ||||
| 		jsonString, err := json.Marshal(policy) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		endpoint.Policies = append(endpoint.Policies, jsonString) | ||||
| 	} | ||||
|  | ||||
| 	_, err := endpoint.Update() | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| // ContainerAttach attaches an endpoint to container | ||||
| func (endpoint *HNSEndpoint) ContainerAttach(containerID string, compartmentID uint16) error { | ||||
| 	operation := "ContainerAttach" | ||||
|   | ||||
							
								
								
									
										10
									
								
								vendor/github.com/Microsoft/hcsshim/internal/hns/hnspolicy.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								vendor/github.com/Microsoft/hcsshim/internal/hns/hnspolicy.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -17,6 +17,7 @@ const ( | ||||
| 	OutboundNat          PolicyType = "OutBoundNAT" | ||||
| 	ExternalLoadBalancer PolicyType = "ELB" | ||||
| 	Route                PolicyType = "ROUTE" | ||||
| 	Proxy                PolicyType = "PROXY" | ||||
| ) | ||||
|  | ||||
| type NatPolicy struct { | ||||
| @@ -60,6 +61,15 @@ type OutboundNatPolicy struct { | ||||
| 	Destinations []string `json:",omitempty"` | ||||
| } | ||||
|  | ||||
| type ProxyPolicy struct { | ||||
| 	Type          PolicyType `json:"Type"` | ||||
| 	IP            string     `json:",omitempty"` | ||||
| 	Port          string     `json:",omitempty"` | ||||
| 	ExceptionList []string   `json:",omitempty"` | ||||
| 	Destination   string     `json:",omitempty"` | ||||
| 	OutboundNat   bool       `json:",omitempty"` | ||||
| } | ||||
|  | ||||
| type ActionType string | ||||
| type DirectionType string | ||||
| type RuleType string | ||||
|   | ||||
							
								
								
									
										7
									
								
								vendor/github.com/Microsoft/hcsshim/internal/schema1/schema1.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								vendor/github.com/Microsoft/hcsshim/internal/schema1/schema1.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -214,9 +214,10 @@ type MappedVirtualDiskController struct { | ||||
|  | ||||
| // GuestDefinedCapabilities is part of the GuestConnectionInfo returned by a GuestConnection call on a utility VM | ||||
| type GuestDefinedCapabilities struct { | ||||
| 	NamespaceAddRequestSupported bool `json:",omitempty"` | ||||
| 	SignalProcessSupported       bool `json:",omitempty"` | ||||
| 	DumpStacksSupported          bool `json:",omitempty"` | ||||
| 	NamespaceAddRequestSupported  bool `json:",omitempty"` | ||||
| 	SignalProcessSupported        bool `json:",omitempty"` | ||||
| 	DumpStacksSupported           bool `json:",omitempty"` | ||||
| 	DeleteContainerStateSupported bool `json:",omitempty"` | ||||
| } | ||||
|  | ||||
| // GuestConnectionInfo is the structure of an iterm return by a GuestConnection call on a utility VM | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/github.com/Microsoft/hcsshim/internal/schema2/devices.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/Microsoft/hcsshim/internal/schema2/devices.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -39,4 +39,8 @@ type Devices struct { | ||||
| 	FlexibleIov map[string]FlexibleIoDevice `json:"FlexibleIov,omitempty"` | ||||
|  | ||||
| 	SharedMemory *SharedMemoryConfiguration `json:"SharedMemory,omitempty"` | ||||
|  | ||||
| 	// TODO: This is pre-release support in schema 2.3. Need to add build number | ||||
| 	// docs when a public build with this is out. | ||||
| 	VirtualPci map[string]VirtualPciDevice `json:",omitempty"` | ||||
| } | ||||
|   | ||||
							
								
								
									
										19
									
								
								vendor/github.com/Microsoft/hcsshim/internal/schema2/memory_2.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										19
									
								
								vendor/github.com/Microsoft/hcsshim/internal/schema2/memory_2.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -27,4 +27,23 @@ type Memory2 struct { | ||||
| 	// to the VM, allowing it to trim non-zeroed pages from the working set (if supported by | ||||
| 	// the guest operating system). | ||||
| 	EnableColdDiscardHint bool `json:"EnableColdDiscardHint,omitempty"` | ||||
|  | ||||
| 	// LowMmioGapInMB is the low MMIO region allocated below 4GB. | ||||
| 	// | ||||
| 	// TODO: This is pre-release support in schema 2.3. Need to add build number | ||||
| 	// docs when a public build with this is out. | ||||
| 	LowMMIOGapInMB uint64 `json:"LowMmioGapInMB,omitempty"` | ||||
|  | ||||
| 	// HighMmioBaseInMB is the high MMIO region allocated above 4GB (base and | ||||
| 	// size). | ||||
| 	// | ||||
| 	// TODO: This is pre-release support in schema 2.3. Need to add build number | ||||
| 	// docs when a public build with this is out. | ||||
| 	HighMMIOBaseInMB uint64 `json:"HighMmioBaseInMB,omitempty"` | ||||
|  | ||||
| 	// HighMmioGapInMB is the high MMIO region. | ||||
| 	// | ||||
| 	// TODO: This is pre-release support in schema 2.3. Need to add build number | ||||
| 	// docs when a public build with this is out. | ||||
| 	HighMMIOGapInMB uint64 `json:"HighMmioGapInMB,omitempty"` | ||||
| } | ||||
|   | ||||
							
								
								
									
										16
									
								
								vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_pci_device.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_pci_device.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| /* | ||||
|  * HCS API | ||||
|  * | ||||
|  * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||||
|  * | ||||
|  * API version: 2.3 | ||||
|  * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||||
|  */ | ||||
|  | ||||
| package hcsschema | ||||
|  | ||||
| // TODO: This is pre-release support in schema 2.3. Need to add build number | ||||
| // docs when a public build with this is out. | ||||
| type VirtualPciDevice struct { | ||||
| 	Functions []VirtualPciFunction `json:",omitempty"` | ||||
| } | ||||
							
								
								
									
										18
									
								
								vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_pci_function.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								vendor/github.com/Microsoft/hcsshim/internal/schema2/virtual_pci_function.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| /* | ||||
|  * HCS API | ||||
|  * | ||||
|  * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||||
|  * | ||||
|  * API version: 2.3 | ||||
|  * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||||
|  */ | ||||
|  | ||||
| package hcsschema | ||||
|  | ||||
| // TODO: This is pre-release support in schema 2.3. Need to add build number | ||||
| // docs when a public build with this is out. | ||||
| type VirtualPciFunction struct { | ||||
| 	DeviceInstancePath string `json:",omitempty"` | ||||
|  | ||||
| 	VirtualFunction uint16 `json:",omitempty"` | ||||
| } | ||||
							
								
								
									
										23
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/activatelayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										23
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/activatelayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,28 +1,23 @@ | ||||
| package wclayer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
|  | ||||
| 	"github.com/Microsoft/hcsshim/internal/hcserror" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/Microsoft/hcsshim/internal/oc" | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| // ActivateLayer will find the layer with the given id and mount it's filesystem. | ||||
| // For a read/write layer, the mounted filesystem will appear as a volume on the | ||||
| // host, while a read-only layer is generally expected to be a no-op. | ||||
| // An activated layer must later be deactivated via DeactivateLayer. | ||||
| func ActivateLayer(path string) (err error) { | ||||
| func ActivateLayer(ctx context.Context, path string) (err error) { | ||||
| 	title := "hcsshim::ActivateLayer" | ||||
| 	fields := logrus.Fields{ | ||||
| 		"path": path, | ||||
| 	} | ||||
| 	logrus.WithFields(fields).Debug(title) | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			fields[logrus.ErrorKey] = err | ||||
| 			logrus.WithFields(fields).Error(err) | ||||
| 		} else { | ||||
| 			logrus.WithFields(fields).Debug(title + " - succeeded") | ||||
| 		} | ||||
| 	}() | ||||
| 	ctx, span := trace.StartSpan(ctx, title) | ||||
| 	defer span.End() | ||||
| 	defer func() { oc.SetSpanStatus(span, err) }() | ||||
| 	span.AddAttributes(trace.StringAttribute("path", path)) | ||||
|  | ||||
| 	err = activateLayer(&stdDriverInfo, path) | ||||
| 	if err != nil { | ||||
|   | ||||
							
								
								
									
										17
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/baselayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										17
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/baselayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,6 +1,7 @@ | ||||
| package wclayer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
| @@ -8,10 +9,15 @@ import ( | ||||
|  | ||||
| 	"github.com/Microsoft/go-winio" | ||||
| 	"github.com/Microsoft/hcsshim/internal/hcserror" | ||||
| 	"github.com/Microsoft/hcsshim/internal/oc" | ||||
| 	"github.com/Microsoft/hcsshim/internal/safefile" | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| type baseLayerWriter struct { | ||||
| 	ctx context.Context | ||||
| 	s   *trace.Span | ||||
|  | ||||
| 	root         *os.File | ||||
| 	f            *os.File | ||||
| 	bw           *winio.BackupFileWriter | ||||
| @@ -136,12 +142,15 @@ func (w *baseLayerWriter) Write(b []byte) (int, error) { | ||||
| 	return n, err | ||||
| } | ||||
|  | ||||
| func (w *baseLayerWriter) Close() error { | ||||
| func (w *baseLayerWriter) Close() (err error) { | ||||
| 	defer w.s.End() | ||||
| 	defer func() { oc.SetSpanStatus(w.s, err) }() | ||||
| 	defer func() { | ||||
| 		w.root.Close() | ||||
| 		w.root = nil | ||||
| 	}() | ||||
| 	err := w.closeCurrentFile() | ||||
|  | ||||
| 	err = w.closeCurrentFile() | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| @@ -153,7 +162,7 @@ func (w *baseLayerWriter) Close() error { | ||||
| 			return err | ||||
| 		} | ||||
|  | ||||
| 		err = ProcessBaseLayer(w.root.Name()) | ||||
| 		err = ProcessBaseLayer(w.ctx, w.root.Name()) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| @@ -163,7 +172,7 @@ func (w *baseLayerWriter) Close() error { | ||||
| 			if err != nil { | ||||
| 				return err | ||||
| 			} | ||||
| 			err = ProcessUtilityVMImage(filepath.Join(w.root.Name(), "UtilityVM")) | ||||
| 			err = ProcessUtilityVMImage(w.ctx, filepath.Join(w.root.Name(), "UtilityVM")) | ||||
| 			if err != nil { | ||||
| 				return err | ||||
| 			} | ||||
|   | ||||
							
								
								
									
										26
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/createlayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										26
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/createlayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,27 +1,23 @@ | ||||
| package wclayer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
|  | ||||
| 	"github.com/Microsoft/hcsshim/internal/hcserror" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/Microsoft/hcsshim/internal/oc" | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| // CreateLayer creates a new, empty, read-only layer on the filesystem based on | ||||
| // the parent layer provided. | ||||
| func CreateLayer(path, parent string) (err error) { | ||||
| func CreateLayer(ctx context.Context, path, parent string) (err error) { | ||||
| 	title := "hcsshim::CreateLayer" | ||||
| 	fields := logrus.Fields{ | ||||
| 		"parent": parent, | ||||
| 		"path":   path, | ||||
| 	} | ||||
| 	logrus.WithFields(fields).Debug(title) | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			fields[logrus.ErrorKey] = err | ||||
| 			logrus.WithFields(fields).Error(err) | ||||
| 		} else { | ||||
| 			logrus.WithFields(fields).Debug(title + " - succeeded") | ||||
| 		} | ||||
| 	}() | ||||
| 	ctx, span := trace.StartSpan(ctx, title) | ||||
| 	defer span.End() | ||||
| 	defer func() { oc.SetSpanStatus(span, err) }() | ||||
| 	span.AddAttributes( | ||||
| 		trace.StringAttribute("path", path), | ||||
| 		trace.StringAttribute("parent", parent)) | ||||
|  | ||||
| 	err = createLayer(&stdDriverInfo, path, parent) | ||||
| 	if err != nil { | ||||
|   | ||||
							
								
								
									
										28
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/createscratchlayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										28
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/createscratchlayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,31 +1,29 @@ | ||||
| package wclayer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/Microsoft/hcsshim/internal/hcserror" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/Microsoft/hcsshim/internal/oc" | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| // CreateScratchLayer creates and populates new read-write layer for use by a container. | ||||
| // This requires both the id of the direct parent layer, as well as the full list | ||||
| // of paths to all parent layers up to the base (and including the direct parent | ||||
| // whose id was provided). | ||||
| func CreateScratchLayer(path string, parentLayerPaths []string) (err error) { | ||||
| func CreateScratchLayer(ctx context.Context, path string, parentLayerPaths []string) (err error) { | ||||
| 	title := "hcsshim::CreateScratchLayer" | ||||
| 	fields := logrus.Fields{ | ||||
| 		"path": path, | ||||
| 	} | ||||
| 	logrus.WithFields(fields).Debug(title) | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			fields[logrus.ErrorKey] = err | ||||
| 			logrus.WithFields(fields).Error(err) | ||||
| 		} else { | ||||
| 			logrus.WithFields(fields).Debug(title + " - succeeded") | ||||
| 		} | ||||
| 	}() | ||||
| 	ctx, span := trace.StartSpan(ctx, title) | ||||
| 	defer span.End() | ||||
| 	defer func() { oc.SetSpanStatus(span, err) }() | ||||
| 	span.AddAttributes( | ||||
| 		trace.StringAttribute("path", path), | ||||
| 		trace.StringAttribute("parentLayerPaths", strings.Join(parentLayerPaths, ", "))) | ||||
|  | ||||
| 	// Generate layer descriptors | ||||
| 	layers, err := layerPathsToDescriptors(parentLayerPaths) | ||||
| 	layers, err := layerPathsToDescriptors(ctx, parentLayerPaths) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										23
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/deactivatelayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										23
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/deactivatelayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,25 +1,20 @@ | ||||
| package wclayer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
|  | ||||
| 	"github.com/Microsoft/hcsshim/internal/hcserror" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/Microsoft/hcsshim/internal/oc" | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| // DeactivateLayer will dismount a layer that was mounted via ActivateLayer. | ||||
| func DeactivateLayer(path string) (err error) { | ||||
| func DeactivateLayer(ctx context.Context, path string) (err error) { | ||||
| 	title := "hcsshim::DeactivateLayer" | ||||
| 	fields := logrus.Fields{ | ||||
| 		"path": path, | ||||
| 	} | ||||
| 	logrus.WithFields(fields).Debug(title) | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			fields[logrus.ErrorKey] = err | ||||
| 			logrus.WithFields(fields).Error(err) | ||||
| 		} else { | ||||
| 			logrus.WithFields(fields).Debug(title + " - succeeded") | ||||
| 		} | ||||
| 	}() | ||||
| 	ctx, span := trace.StartSpan(ctx, title) | ||||
| 	defer span.End() | ||||
| 	defer func() { oc.SetSpanStatus(span, err) }() | ||||
| 	span.AddAttributes(trace.StringAttribute("path", path)) | ||||
|  | ||||
| 	err = deactivateLayer(&stdDriverInfo, path) | ||||
| 	if err != nil { | ||||
|   | ||||
							
								
								
									
										23
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/destroylayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										23
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/destroylayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,26 +1,21 @@ | ||||
| package wclayer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
|  | ||||
| 	"github.com/Microsoft/hcsshim/internal/hcserror" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/Microsoft/hcsshim/internal/oc" | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| // DestroyLayer will remove the on-disk files representing the layer with the given | ||||
| // path, including that layer's containing folder, if any. | ||||
| func DestroyLayer(path string) (err error) { | ||||
| func DestroyLayer(ctx context.Context, path string) (err error) { | ||||
| 	title := "hcsshim::DestroyLayer" | ||||
| 	fields := logrus.Fields{ | ||||
| 		"path": path, | ||||
| 	} | ||||
| 	logrus.WithFields(fields).Debug(title) | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			fields[logrus.ErrorKey] = err | ||||
| 			logrus.WithFields(fields).Error(err) | ||||
| 		} else { | ||||
| 			logrus.WithFields(fields).Debug(title + " - succeeded") | ||||
| 		} | ||||
| 	}() | ||||
| 	ctx, span := trace.StartSpan(ctx, title) | ||||
| 	defer span.End() | ||||
| 	defer func() { oc.SetSpanStatus(span, err) }() | ||||
| 	span.AddAttributes(trace.StringAttribute("path", path)) | ||||
|  | ||||
| 	err = destroyLayer(&stdDriverInfo, path) | ||||
| 	if err != nil { | ||||
|   | ||||
							
								
								
									
										31
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/expandscratchsize.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										31
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/expandscratchsize.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,32 +1,27 @@ | ||||
| package wclayer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
| 	"syscall" | ||||
| 	"unsafe" | ||||
|  | ||||
| 	"github.com/Microsoft/hcsshim/internal/hcserror" | ||||
| 	"github.com/Microsoft/hcsshim/internal/oc" | ||||
| 	"github.com/Microsoft/hcsshim/osversion" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| // ExpandScratchSize expands the size of a layer to at least size bytes. | ||||
| func ExpandScratchSize(path string, size uint64) (err error) { | ||||
| func ExpandScratchSize(ctx context.Context, path string, size uint64) (err error) { | ||||
| 	title := "hcsshim::ExpandScratchSize" | ||||
| 	fields := logrus.Fields{ | ||||
| 		"path": path, | ||||
| 		"size": size, | ||||
| 	} | ||||
| 	logrus.WithFields(fields).Debug(title) | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			fields[logrus.ErrorKey] = err | ||||
| 			logrus.WithFields(fields).Error(err) | ||||
| 		} else { | ||||
| 			logrus.WithFields(fields).Debug(title + " - succeeded") | ||||
| 		} | ||||
| 	}() | ||||
| 	ctx, span := trace.StartSpan(ctx, title) | ||||
| 	defer span.End() | ||||
| 	defer func() { oc.SetSpanStatus(span, err) }() | ||||
| 	span.AddAttributes( | ||||
| 		trace.StringAttribute("path", path), | ||||
| 		trace.Int64Attribute("size", int64(size))) | ||||
|  | ||||
| 	err = expandSandboxSize(&stdDriverInfo, path, size) | ||||
| 	if err != nil { | ||||
| @@ -36,7 +31,7 @@ func ExpandScratchSize(path string, size uint64) (err error) { | ||||
| 	// Manually expand the volume now in order to work around bugs in 19H1 and | ||||
| 	// prerelease versions of Vb. Remove once this is fixed in Windows. | ||||
| 	if build := osversion.Get().Build; build >= osversion.V19H1 && build < 19020 { | ||||
| 		err = expandSandboxVolume(path) | ||||
| 		err = expandSandboxVolume(ctx, path) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| @@ -84,7 +79,7 @@ func attachVhd(path string) (syscall.Handle, error) { | ||||
| 	return handle, nil | ||||
| } | ||||
|  | ||||
| func expandSandboxVolume(path string) error { | ||||
| func expandSandboxVolume(ctx context.Context, path string) error { | ||||
| 	// Mount the sandbox VHD temporarily. | ||||
| 	vhdPath := filepath.Join(path, "sandbox.vhdx") | ||||
| 	vhd, err := attachVhd(vhdPath) | ||||
| @@ -94,7 +89,7 @@ func expandSandboxVolume(path string) error { | ||||
| 	defer syscall.Close(vhd) | ||||
|  | ||||
| 	// Open the volume. | ||||
| 	volumePath, err := GetLayerMountPath(path) | ||||
| 	volumePath, err := GetLayerMountPath(ctx, path) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										60
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/exportlayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										60
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/exportlayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,12 +1,15 @@ | ||||
| package wclayer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"io/ioutil" | ||||
| 	"os" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/Microsoft/go-winio" | ||||
| 	"github.com/Microsoft/hcsshim/internal/hcserror" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/Microsoft/hcsshim/internal/oc" | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| // ExportLayer will create a folder at exportFolderPath and fill that folder with | ||||
| @@ -14,24 +17,18 @@ import ( | ||||
| // format includes any metadata required for later importing the layer (using | ||||
| // ImportLayer), and requires the full list of parent layer paths in order to | ||||
| // perform the export. | ||||
| func ExportLayer(path string, exportFolderPath string, parentLayerPaths []string) (err error) { | ||||
| func ExportLayer(ctx context.Context, path string, exportFolderPath string, parentLayerPaths []string) (err error) { | ||||
| 	title := "hcsshim::ExportLayer" | ||||
| 	fields := logrus.Fields{ | ||||
| 		"path":             path, | ||||
| 		"exportFolderPath": exportFolderPath, | ||||
| 	} | ||||
| 	logrus.WithFields(fields).Debug(title) | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			fields[logrus.ErrorKey] = err | ||||
| 			logrus.WithFields(fields).Error(err) | ||||
| 		} else { | ||||
| 			logrus.WithFields(fields).Debug(title + " - succeeded") | ||||
| 		} | ||||
| 	}() | ||||
| 	ctx, span := trace.StartSpan(ctx, title) | ||||
| 	defer span.End() | ||||
| 	defer func() { oc.SetSpanStatus(span, err) }() | ||||
| 	span.AddAttributes( | ||||
| 		trace.StringAttribute("path", path), | ||||
| 		trace.StringAttribute("exportFolderPath", exportFolderPath), | ||||
| 		trace.StringAttribute("parentLayerPaths", strings.Join(parentLayerPaths, ", "))) | ||||
|  | ||||
| 	// Generate layer descriptors | ||||
| 	layers, err := layerPathsToDescriptors(parentLayerPaths) | ||||
| 	layers, err := layerPathsToDescriptors(ctx, parentLayerPaths) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| @@ -52,25 +49,46 @@ type LayerReader interface { | ||||
| // NewLayerReader returns a new layer reader for reading the contents of an on-disk layer. | ||||
| // The caller must have taken the SeBackupPrivilege privilege | ||||
| // to call this and any methods on the resulting LayerReader. | ||||
| func NewLayerReader(path string, parentLayerPaths []string) (LayerReader, error) { | ||||
| func NewLayerReader(ctx context.Context, path string, parentLayerPaths []string) (_ LayerReader, err error) { | ||||
| 	ctx, span := trace.StartSpan(ctx, "hcsshim::NewLayerReader") | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			oc.SetSpanStatus(span, err) | ||||
| 			span.End() | ||||
| 		} | ||||
| 	}() | ||||
| 	span.AddAttributes( | ||||
| 		trace.StringAttribute("path", path), | ||||
| 		trace.StringAttribute("parentLayerPaths", strings.Join(parentLayerPaths, ", "))) | ||||
|  | ||||
| 	exportPath, err := ioutil.TempDir("", "hcs") | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	err = ExportLayer(path, exportPath, parentLayerPaths) | ||||
| 	err = ExportLayer(ctx, path, exportPath, parentLayerPaths) | ||||
| 	if err != nil { | ||||
| 		os.RemoveAll(exportPath) | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return &legacyLayerReaderWrapper{newLegacyLayerReader(exportPath)}, nil | ||||
| 	return &legacyLayerReaderWrapper{ | ||||
| 		ctx:               ctx, | ||||
| 		s:                 span, | ||||
| 		legacyLayerReader: newLegacyLayerReader(exportPath), | ||||
| 	}, nil | ||||
| } | ||||
|  | ||||
| type legacyLayerReaderWrapper struct { | ||||
| 	ctx context.Context | ||||
| 	s   *trace.Span | ||||
|  | ||||
| 	*legacyLayerReader | ||||
| } | ||||
|  | ||||
| func (r *legacyLayerReaderWrapper) Close() error { | ||||
| 	err := r.legacyLayerReader.Close() | ||||
| func (r *legacyLayerReaderWrapper) Close() (err error) { | ||||
| 	defer r.s.End() | ||||
| 	defer func() { oc.SetSpanStatus(r.s, err) }() | ||||
|  | ||||
| 	err = r.legacyLayerReader.Close() | ||||
| 	os.RemoveAll(r.root) | ||||
| 	return err | ||||
| } | ||||
|   | ||||
							
								
								
									
										29
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/getlayermountpath.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										29
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/getlayermountpath.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,36 +1,31 @@ | ||||
| package wclayer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"syscall" | ||||
|  | ||||
| 	"github.com/Microsoft/hcsshim/internal/hcserror" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/Microsoft/hcsshim/internal/log" | ||||
| 	"github.com/Microsoft/hcsshim/internal/oc" | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| // GetLayerMountPath will look for a mounted layer with the given path and return | ||||
| // the path at which that layer can be accessed.  This path may be a volume path | ||||
| // if the layer is a mounted read-write layer, otherwise it is expected to be the | ||||
| // folder path at which the layer is stored. | ||||
| func GetLayerMountPath(path string) (_ string, err error) { | ||||
| func GetLayerMountPath(ctx context.Context, path string) (_ string, err error) { | ||||
| 	title := "hcsshim::GetLayerMountPath" | ||||
| 	fields := logrus.Fields{ | ||||
| 		"path": path, | ||||
| 	} | ||||
| 	logrus.WithFields(fields).Debug(title) | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			fields[logrus.ErrorKey] = err | ||||
| 			logrus.WithFields(fields).Error(err) | ||||
| 		} else { | ||||
| 			logrus.WithFields(fields).Debug(title + " - succeeded") | ||||
| 		} | ||||
| 	}() | ||||
| 	ctx, span := trace.StartSpan(ctx, title) | ||||
| 	defer span.End() | ||||
| 	defer func() { oc.SetSpanStatus(span, err) }() | ||||
| 	span.AddAttributes(trace.StringAttribute("path", path)) | ||||
|  | ||||
| 	var mountPathLength uintptr | ||||
| 	mountPathLength = 0 | ||||
|  | ||||
| 	// Call the procedure itself. | ||||
| 	logrus.WithFields(fields).Debug("Calling proc (1)") | ||||
| 	log.G(ctx).Debug("Calling proc (1)") | ||||
| 	err = getLayerMountPath(&stdDriverInfo, path, &mountPathLength, nil) | ||||
| 	if err != nil { | ||||
| 		return "", hcserror.New(err, title+" - failed", "(first call)") | ||||
| @@ -44,13 +39,13 @@ func GetLayerMountPath(path string) (_ string, err error) { | ||||
| 	mountPathp[0] = 0 | ||||
|  | ||||
| 	// Call the procedure again | ||||
| 	logrus.WithFields(fields).Debug("Calling proc (2)") | ||||
| 	log.G(ctx).Debug("Calling proc (2)") | ||||
| 	err = getLayerMountPath(&stdDriverInfo, path, &mountPathLength, &mountPathp[0]) | ||||
| 	if err != nil { | ||||
| 		return "", hcserror.New(err, title+" - failed", "(second call)") | ||||
| 	} | ||||
|  | ||||
| 	mountPath := syscall.UTF16ToString(mountPathp[0:]) | ||||
| 	fields["mountPath"] = mountPath | ||||
| 	span.AddAttributes(trace.StringAttribute("mountPath", mountPath)) | ||||
| 	return mountPath, nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										22
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/getsharedbaseimages.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										22
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/getsharedbaseimages.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,29 +1,29 @@ | ||||
| package wclayer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
|  | ||||
| 	"github.com/Microsoft/hcsshim/internal/hcserror" | ||||
| 	"github.com/Microsoft/hcsshim/internal/interop" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/Microsoft/hcsshim/internal/oc" | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| // GetSharedBaseImages will enumerate the images stored in the common central | ||||
| // image store and return descriptive info about those images for the purpose | ||||
| // of registering them with the graphdriver, graph, and tagstore. | ||||
| func GetSharedBaseImages() (imageData string, err error) { | ||||
| func GetSharedBaseImages(ctx context.Context) (_ string, err error) { | ||||
| 	title := "hcsshim::GetSharedBaseImages" | ||||
| 	logrus.Debug(title) | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			logrus.WithError(err).Error(err) | ||||
| 		} else { | ||||
| 			logrus.WithField("imageData", imageData).Debug(title + " - succeeded") | ||||
| 		} | ||||
| 	}() | ||||
| 	ctx, span := trace.StartSpan(ctx, title) | ||||
| 	defer span.End() | ||||
| 	defer func() { oc.SetSpanStatus(span, err) }() | ||||
|  | ||||
| 	var buffer *uint16 | ||||
| 	err = getBaseImages(&buffer) | ||||
| 	if err != nil { | ||||
| 		return "", hcserror.New(err, title+" - failed", "") | ||||
| 	} | ||||
| 	return interop.ConvertAndFreeCoTaskMemString(buffer), nil | ||||
| 	imageData := interop.ConvertAndFreeCoTaskMemString(buffer) | ||||
| 	span.AddAttributes(trace.StringAttribute("imageData", imageData)) | ||||
| 	return imageData, nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										26
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/grantvmaccess.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										26
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/grantvmaccess.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,26 +1,22 @@ | ||||
| package wclayer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
|  | ||||
| 	"github.com/Microsoft/hcsshim/internal/hcserror" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/Microsoft/hcsshim/internal/oc" | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| // GrantVmAccess adds access to a file for a given VM | ||||
| func GrantVmAccess(vmid string, filepath string) (err error) { | ||||
| func GrantVmAccess(ctx context.Context, vmid string, filepath string) (err error) { | ||||
| 	title := "hcsshim::GrantVmAccess" | ||||
| 	fields := logrus.Fields{ | ||||
| 		"vm-id": vmid, | ||||
| 		"path":  filepath, | ||||
| 	} | ||||
| 	logrus.WithFields(fields).Debug(title) | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			fields[logrus.ErrorKey] = err | ||||
| 			logrus.WithFields(fields).Error(err) | ||||
| 		} else { | ||||
| 			logrus.WithFields(fields).Debug(title + " - succeeded") | ||||
| 		} | ||||
| 	}() | ||||
| 	ctx, span := trace.StartSpan(ctx, title) | ||||
| 	defer span.End() | ||||
| 	defer func() { oc.SetSpanStatus(span, err) }() | ||||
| 	span.AddAttributes( | ||||
| 		trace.StringAttribute("vm-id", vmid), | ||||
| 		trace.StringAttribute("path", filepath)) | ||||
|  | ||||
| 	err = grantVmAccess(vmid, filepath) | ||||
| 	if err != nil { | ||||
|   | ||||
							
								
								
									
										60
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/importlayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										60
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/importlayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,38 +1,35 @@ | ||||
| package wclayer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"io/ioutil" | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/Microsoft/go-winio" | ||||
| 	"github.com/Microsoft/hcsshim/internal/hcserror" | ||||
| 	"github.com/Microsoft/hcsshim/internal/oc" | ||||
| 	"github.com/Microsoft/hcsshim/internal/safefile" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| // ImportLayer will take the contents of the folder at importFolderPath and import | ||||
| // that into a layer with the id layerId.  Note that in order to correctly populate | ||||
| // the layer and interperet the transport format, all parent layers must already | ||||
| // be present on the system at the paths provided in parentLayerPaths. | ||||
| func ImportLayer(path string, importFolderPath string, parentLayerPaths []string) (err error) { | ||||
| func ImportLayer(ctx context.Context, path string, importFolderPath string, parentLayerPaths []string) (err error) { | ||||
| 	title := "hcsshim::ImportLayer" | ||||
| 	fields := logrus.Fields{ | ||||
| 		"path":             path, | ||||
| 		"importFolderPath": importFolderPath, | ||||
| 	} | ||||
| 	logrus.WithFields(fields).Debug(title) | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			fields[logrus.ErrorKey] = err | ||||
| 			logrus.WithFields(fields).Error(err) | ||||
| 		} else { | ||||
| 			logrus.WithFields(fields).Debug(title + " - succeeded") | ||||
| 		} | ||||
| 	}() | ||||
| 	ctx, span := trace.StartSpan(ctx, title) | ||||
| 	defer span.End() | ||||
| 	defer func() { oc.SetSpanStatus(span, err) }() | ||||
| 	span.AddAttributes( | ||||
| 		trace.StringAttribute("path", path), | ||||
| 		trace.StringAttribute("importFolderPath", importFolderPath), | ||||
| 		trace.StringAttribute("parentLayerPaths", strings.Join(parentLayerPaths, ", "))) | ||||
|  | ||||
| 	// Generate layer descriptors | ||||
| 	layers, err := layerPathsToDescriptors(parentLayerPaths) | ||||
| 	layers, err := layerPathsToDescriptors(ctx, parentLayerPaths) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| @@ -60,20 +57,26 @@ type LayerWriter interface { | ||||
| } | ||||
|  | ||||
| type legacyLayerWriterWrapper struct { | ||||
| 	ctx context.Context | ||||
| 	s   *trace.Span | ||||
|  | ||||
| 	*legacyLayerWriter | ||||
| 	path             string | ||||
| 	parentLayerPaths []string | ||||
| } | ||||
|  | ||||
| func (r *legacyLayerWriterWrapper) Close() error { | ||||
| func (r *legacyLayerWriterWrapper) Close() (err error) { | ||||
| 	defer r.s.End() | ||||
| 	defer func() { oc.SetSpanStatus(r.s, err) }() | ||||
| 	defer os.RemoveAll(r.root.Name()) | ||||
| 	defer r.legacyLayerWriter.CloseRoots() | ||||
| 	err := r.legacyLayerWriter.Close() | ||||
|  | ||||
| 	err = r.legacyLayerWriter.Close() | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	if err = ImportLayer(r.destRoot.Name(), r.path, r.parentLayerPaths); err != nil { | ||||
| 	if err = ImportLayer(r.ctx, r.destRoot.Name(), r.path, r.parentLayerPaths); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	for _, name := range r.Tombstones { | ||||
| @@ -96,7 +99,7 @@ func (r *legacyLayerWriterWrapper) Close() error { | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 		err = ProcessUtilityVMImage(filepath.Join(r.destRoot.Name(), "UtilityVM")) | ||||
| 		err = ProcessUtilityVMImage(r.ctx, filepath.Join(r.destRoot.Name(), "UtilityVM")) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| @@ -107,7 +110,18 @@ func (r *legacyLayerWriterWrapper) Close() error { | ||||
| // NewLayerWriter returns a new layer writer for creating a layer on disk. | ||||
| // The caller must have taken the SeBackupPrivilege and SeRestorePrivilege privileges | ||||
| // to call this and any methods on the resulting LayerWriter. | ||||
| func NewLayerWriter(path string, parentLayerPaths []string) (LayerWriter, error) { | ||||
| func NewLayerWriter(ctx context.Context, path string, parentLayerPaths []string) (_ LayerWriter, err error) { | ||||
| 	ctx, span := trace.StartSpan(ctx, "hcsshim::NewLayerWriter") | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			oc.SetSpanStatus(span, err) | ||||
| 			span.End() | ||||
| 		} | ||||
| 	}() | ||||
| 	span.AddAttributes( | ||||
| 		trace.StringAttribute("path", path), | ||||
| 		trace.StringAttribute("parentLayerPaths", strings.Join(parentLayerPaths, ", "))) | ||||
|  | ||||
| 	if len(parentLayerPaths) == 0 { | ||||
| 		// This is a base layer. It gets imported differently. | ||||
| 		f, err := safefile.OpenRoot(path) | ||||
| @@ -115,6 +129,8 @@ func NewLayerWriter(path string, parentLayerPaths []string) (LayerWriter, error) | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		return &baseLayerWriter{ | ||||
| 			ctx:  ctx, | ||||
| 			s:    span, | ||||
| 			root: f, | ||||
| 		}, nil | ||||
| 	} | ||||
| @@ -128,6 +144,8 @@ func NewLayerWriter(path string, parentLayerPaths []string) (LayerWriter, error) | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return &legacyLayerWriterWrapper{ | ||||
| 		ctx:               ctx, | ||||
| 		s:                 span, | ||||
| 		legacyLayerWriter: w, | ||||
| 		path:              importPath, | ||||
| 		parentLayerPaths:  parentLayerPaths, | ||||
|   | ||||
							
								
								
									
										25
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerexists.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										25
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerexists.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,26 +1,21 @@ | ||||
| package wclayer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
|  | ||||
| 	"github.com/Microsoft/hcsshim/internal/hcserror" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/Microsoft/hcsshim/internal/oc" | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| // LayerExists will return true if a layer with the given id exists and is known | ||||
| // to the system. | ||||
| func LayerExists(path string) (_ bool, err error) { | ||||
| func LayerExists(ctx context.Context, path string) (_ bool, err error) { | ||||
| 	title := "hcsshim::LayerExists" | ||||
| 	fields := logrus.Fields{ | ||||
| 		"path": path, | ||||
| 	} | ||||
| 	logrus.WithFields(fields).Debug(title) | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			fields[logrus.ErrorKey] = err | ||||
| 			logrus.WithFields(fields).Error(err) | ||||
| 		} else { | ||||
| 			logrus.WithFields(fields).Debug(title + " - succeeded") | ||||
| 		} | ||||
| 	}() | ||||
| 	ctx, span := trace.StartSpan(ctx, title) | ||||
| 	defer span.End() | ||||
| 	defer func() { oc.SetSpanStatus(span, err) }() | ||||
| 	span.AddAttributes(trace.StringAttribute("path", path)) | ||||
|  | ||||
| 	// Call the procedure itself. | ||||
| 	var exists uint32 | ||||
| @@ -28,6 +23,6 @@ func LayerExists(path string) (_ bool, err error) { | ||||
| 	if err != nil { | ||||
| 		return false, hcserror.New(err, title+" - failed", "") | ||||
| 	} | ||||
| 	fields["layer-exists"] = exists != 0 | ||||
| 	span.AddAttributes(trace.BoolAttribute("layer-exists", exists != 0)) | ||||
| 	return exists != 0, nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										13
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerid.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										13
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerid.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,13 +1,22 @@ | ||||
| package wclayer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"path/filepath" | ||||
|  | ||||
| 	"github.com/Microsoft/go-winio/pkg/guid" | ||||
| 	"github.com/Microsoft/hcsshim/internal/oc" | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| // LayerID returns the layer ID of a layer on disk. | ||||
| func LayerID(path string) (guid.GUID, error) { | ||||
| func LayerID(ctx context.Context, path string) (_ guid.GUID, err error) { | ||||
| 	title := "hcsshim::LayerID" | ||||
| 	ctx, span := trace.StartSpan(ctx, title) | ||||
| 	defer span.End() | ||||
| 	defer func() { oc.SetSpanStatus(span, err) }() | ||||
| 	span.AddAttributes(trace.StringAttribute("path", path)) | ||||
|  | ||||
| 	_, file := filepath.Split(path) | ||||
| 	return NameToGuid(file) | ||||
| 	return NameToGuid(ctx, file) | ||||
| } | ||||
|   | ||||
							
								
								
									
										5
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerutils.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerutils.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -4,6 +4,7 @@ package wclayer | ||||
| // functionality. | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"syscall" | ||||
|  | ||||
| 	"github.com/Microsoft/go-winio/pkg/guid" | ||||
| @@ -68,12 +69,12 @@ type WC_LAYER_DESCRIPTOR struct { | ||||
| 	Pathp   *uint16 | ||||
| } | ||||
|  | ||||
| func layerPathsToDescriptors(parentLayerPaths []string) ([]WC_LAYER_DESCRIPTOR, error) { | ||||
| func layerPathsToDescriptors(ctx context.Context, parentLayerPaths []string) ([]WC_LAYER_DESCRIPTOR, error) { | ||||
| 	// Array of descriptors that gets constructed. | ||||
| 	var layers []WC_LAYER_DESCRIPTOR | ||||
|  | ||||
| 	for i := 0; i < len(parentLayerPaths); i++ { | ||||
| 		g, err := LayerID(parentLayerPaths[i]) | ||||
| 		g, err := LayerID(ctx, parentLayerPaths[i]) | ||||
| 		if err != nil { | ||||
| 			logrus.WithError(err).Debug("Failed to convert name to guid") | ||||
| 			return nil, err | ||||
|   | ||||
							
								
								
									
										31
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/nametoguid.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										31
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/nametoguid.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,34 +1,29 @@ | ||||
| package wclayer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
|  | ||||
| 	"github.com/Microsoft/go-winio/pkg/guid" | ||||
| 	"github.com/Microsoft/hcsshim/internal/hcserror" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/Microsoft/hcsshim/internal/oc" | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| // NameToGuid converts the given string into a GUID using the algorithm in the | ||||
| // Host Compute Service, ensuring GUIDs generated with the same string are common | ||||
| // across all clients. | ||||
| func NameToGuid(name string) (id guid.GUID, err error) { | ||||
| func NameToGuid(ctx context.Context, name string) (_ guid.GUID, err error) { | ||||
| 	title := "hcsshim::NameToGuid" | ||||
| 	fields := logrus.Fields{ | ||||
| 		"name": name, | ||||
| 	} | ||||
| 	logrus.WithFields(fields).Debug(title) | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			fields[logrus.ErrorKey] = err | ||||
| 			logrus.WithFields(fields).Error(err) | ||||
| 		} else { | ||||
| 			logrus.WithFields(fields).Debug(title + " - succeeded") | ||||
| 		} | ||||
| 	}() | ||||
| 	ctx, span := trace.StartSpan(ctx, title) | ||||
| 	defer span.End() | ||||
| 	defer func() { oc.SetSpanStatus(span, err) }() | ||||
| 	span.AddAttributes(trace.StringAttribute("name", name)) | ||||
|  | ||||
| 	var id guid.GUID | ||||
| 	err = nameToGuid(name, &id) | ||||
| 	if err != nil { | ||||
| 		err = hcserror.New(err, title+" - failed", "") | ||||
| 		return | ||||
| 		return guid.GUID{}, hcserror.New(err, title+" - failed", "") | ||||
| 	} | ||||
| 	fields["guid"] = id.String() | ||||
| 	return | ||||
| 	span.AddAttributes(trace.StringAttribute("guid", id.String())) | ||||
| 	return id, nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										27
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/preparelayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										27
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/preparelayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,10 +1,13 @@ | ||||
| package wclayer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
|  | ||||
| 	"github.com/Microsoft/hcsshim/internal/hcserror" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/Microsoft/hcsshim/internal/oc" | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| var prepareLayerLock sync.Mutex | ||||
| @@ -14,23 +17,17 @@ var prepareLayerLock sync.Mutex | ||||
| // parent layers, and is necessary in order to view or interact with the layer | ||||
| // as an actual filesystem (reading and writing files, creating directories, etc). | ||||
| // Disabling the filter must be done via UnprepareLayer. | ||||
| func PrepareLayer(path string, parentLayerPaths []string) (err error) { | ||||
| func PrepareLayer(ctx context.Context, path string, parentLayerPaths []string) (err error) { | ||||
| 	title := "hcsshim::PrepareLayer" | ||||
| 	fields := logrus.Fields{ | ||||
| 		"path": path, | ||||
| 	} | ||||
| 	logrus.WithFields(fields).Debug(title) | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			fields[logrus.ErrorKey] = err | ||||
| 			logrus.WithFields(fields).Error(err) | ||||
| 		} else { | ||||
| 			logrus.WithFields(fields).Debug(title + " - succeeded") | ||||
| 		} | ||||
| 	}() | ||||
| 	ctx, span := trace.StartSpan(ctx, title) | ||||
| 	defer span.End() | ||||
| 	defer func() { oc.SetSpanStatus(span, err) }() | ||||
| 	span.AddAttributes( | ||||
| 		trace.StringAttribute("path", path), | ||||
| 		trace.StringAttribute("parentLayerPaths", strings.Join(parentLayerPaths, ", "))) | ||||
|  | ||||
| 	// Generate layer descriptors | ||||
| 	layers, err := layerPathsToDescriptors(parentLayerPaths) | ||||
| 	layers, err := layerPathsToDescriptors(ctx, parentLayerPaths) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										32
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/processimage.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										32
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/processimage.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,23 +1,41 @@ | ||||
| package wclayer | ||||
|  | ||||
| import "os" | ||||
| import ( | ||||
| 	"context" | ||||
| 	"os" | ||||
|  | ||||
| 	"github.com/Microsoft/hcsshim/internal/oc" | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| // ProcessBaseLayer post-processes a base layer that has had its files extracted. | ||||
| // The files should have been extracted to <path>\Files. | ||||
| func ProcessBaseLayer(path string) error { | ||||
| 	err := processBaseImage(path) | ||||
| func ProcessBaseLayer(ctx context.Context, path string) (err error) { | ||||
| 	title := "hcsshim::ProcessBaseLayer" | ||||
| 	ctx, span := trace.StartSpan(ctx, title) | ||||
| 	defer span.End() | ||||
| 	defer func() { oc.SetSpanStatus(span, err) }() | ||||
| 	span.AddAttributes(trace.StringAttribute("path", path)) | ||||
|  | ||||
| 	err = processBaseImage(path) | ||||
| 	if err != nil { | ||||
| 		return &os.PathError{Op: "ProcessBaseLayer", Path: path, Err: err} | ||||
| 		return &os.PathError{Op: title, Path: path, Err: err} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // ProcessUtilityVMImage post-processes a utility VM image that has had its files extracted. | ||||
| // The files should have been extracted to <path>\Files. | ||||
| func ProcessUtilityVMImage(path string) error { | ||||
| 	err := processUtilityImage(path) | ||||
| func ProcessUtilityVMImage(ctx context.Context, path string) (err error) { | ||||
| 	title := "hcsshim::ProcessUtilityVMImage" | ||||
| 	ctx, span := trace.StartSpan(ctx, title) | ||||
| 	defer span.End() | ||||
| 	defer func() { oc.SetSpanStatus(span, err) }() | ||||
| 	span.AddAttributes(trace.StringAttribute("path", path)) | ||||
|  | ||||
| 	err = processUtilityImage(path) | ||||
| 	if err != nil { | ||||
| 		return &os.PathError{Op: "ProcessUtilityVMImage", Path: path, Err: err} | ||||
| 		return &os.PathError{Op: title, Path: path, Err: err} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										23
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/unpreparelayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										23
									
								
								vendor/github.com/Microsoft/hcsshim/internal/wclayer/unpreparelayer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,26 +1,21 @@ | ||||
| package wclayer | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
|  | ||||
| 	"github.com/Microsoft/hcsshim/internal/hcserror" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"github.com/Microsoft/hcsshim/internal/oc" | ||||
| 	"go.opencensus.io/trace" | ||||
| ) | ||||
|  | ||||
| // UnprepareLayer disables the filesystem filter for the read-write layer with | ||||
| // the given id. | ||||
| func UnprepareLayer(path string) (err error) { | ||||
| func UnprepareLayer(ctx context.Context, path string) (err error) { | ||||
| 	title := "hcsshim::UnprepareLayer" | ||||
| 	fields := logrus.Fields{ | ||||
| 		"path": path, | ||||
| 	} | ||||
| 	logrus.WithFields(fields).Debug(title) | ||||
| 	defer func() { | ||||
| 		if err != nil { | ||||
| 			fields[logrus.ErrorKey] = err | ||||
| 			logrus.WithFields(fields).Error(err) | ||||
| 		} else { | ||||
| 			logrus.WithFields(fields).Debug(title + " - succeeded") | ||||
| 		} | ||||
| 	}() | ||||
| 	ctx, span := trace.StartSpan(ctx, title) | ||||
| 	defer span.End() | ||||
| 	defer func() { oc.SetSpanStatus(span, err) }() | ||||
| 	span.AddAttributes(trace.StringAttribute("path", path)) | ||||
|  | ||||
| 	err = unprepareLayer(&stdDriverInfo, path) | ||||
| 	if err != nil { | ||||
|   | ||||
							
								
								
									
										41
									
								
								vendor/github.com/Microsoft/hcsshim/layer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										41
									
								
								vendor/github.com/Microsoft/hcsshim/layer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,6 +1,7 @@ | ||||
| package hcsshim | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"crypto/sha1" | ||||
| 	"path/filepath" | ||||
|  | ||||
| @@ -13,59 +14,59 @@ func layerPath(info *DriverInfo, id string) string { | ||||
| } | ||||
|  | ||||
| func ActivateLayer(info DriverInfo, id string) error { | ||||
| 	return wclayer.ActivateLayer(layerPath(&info, id)) | ||||
| 	return wclayer.ActivateLayer(context.Background(), layerPath(&info, id)) | ||||
| } | ||||
| func CreateLayer(info DriverInfo, id, parent string) error { | ||||
| 	return wclayer.CreateLayer(layerPath(&info, id), parent) | ||||
| 	return wclayer.CreateLayer(context.Background(), layerPath(&info, id), parent) | ||||
| } | ||||
|  | ||||
| // New clients should use CreateScratchLayer instead. Kept in to preserve API compatibility. | ||||
| func CreateSandboxLayer(info DriverInfo, layerId, parentId string, parentLayerPaths []string) error { | ||||
| 	return wclayer.CreateScratchLayer(layerPath(&info, layerId), parentLayerPaths) | ||||
| 	return wclayer.CreateScratchLayer(context.Background(), layerPath(&info, layerId), parentLayerPaths) | ||||
| } | ||||
| func CreateScratchLayer(info DriverInfo, layerId, parentId string, parentLayerPaths []string) error { | ||||
| 	return wclayer.CreateScratchLayer(layerPath(&info, layerId), parentLayerPaths) | ||||
| 	return wclayer.CreateScratchLayer(context.Background(), layerPath(&info, layerId), parentLayerPaths) | ||||
| } | ||||
| func DeactivateLayer(info DriverInfo, id string) error { | ||||
| 	return wclayer.DeactivateLayer(layerPath(&info, id)) | ||||
| 	return wclayer.DeactivateLayer(context.Background(), layerPath(&info, id)) | ||||
| } | ||||
| func DestroyLayer(info DriverInfo, id string) error { | ||||
| 	return wclayer.DestroyLayer(layerPath(&info, id)) | ||||
| 	return wclayer.DestroyLayer(context.Background(), layerPath(&info, id)) | ||||
| } | ||||
|  | ||||
| // New clients should use ExpandScratchSize instead. Kept in to preserve API compatibility. | ||||
| func ExpandSandboxSize(info DriverInfo, layerId string, size uint64) error { | ||||
| 	return wclayer.ExpandScratchSize(layerPath(&info, layerId), size) | ||||
| 	return wclayer.ExpandScratchSize(context.Background(), layerPath(&info, layerId), size) | ||||
| } | ||||
| func ExpandScratchSize(info DriverInfo, layerId string, size uint64) error { | ||||
| 	return wclayer.ExpandScratchSize(layerPath(&info, layerId), size) | ||||
| 	return wclayer.ExpandScratchSize(context.Background(), layerPath(&info, layerId), size) | ||||
| } | ||||
| func ExportLayer(info DriverInfo, layerId string, exportFolderPath string, parentLayerPaths []string) error { | ||||
| 	return wclayer.ExportLayer(layerPath(&info, layerId), exportFolderPath, parentLayerPaths) | ||||
| 	return wclayer.ExportLayer(context.Background(), layerPath(&info, layerId), exportFolderPath, parentLayerPaths) | ||||
| } | ||||
| func GetLayerMountPath(info DriverInfo, id string) (string, error) { | ||||
| 	return wclayer.GetLayerMountPath(layerPath(&info, id)) | ||||
| 	return wclayer.GetLayerMountPath(context.Background(), layerPath(&info, id)) | ||||
| } | ||||
| func GetSharedBaseImages() (imageData string, err error) { | ||||
| 	return wclayer.GetSharedBaseImages() | ||||
| 	return wclayer.GetSharedBaseImages(context.Background()) | ||||
| } | ||||
| func ImportLayer(info DriverInfo, layerID string, importFolderPath string, parentLayerPaths []string) error { | ||||
| 	return wclayer.ImportLayer(layerPath(&info, layerID), importFolderPath, parentLayerPaths) | ||||
| 	return wclayer.ImportLayer(context.Background(), layerPath(&info, layerID), importFolderPath, parentLayerPaths) | ||||
| } | ||||
| func LayerExists(info DriverInfo, id string) (bool, error) { | ||||
| 	return wclayer.LayerExists(layerPath(&info, id)) | ||||
| 	return wclayer.LayerExists(context.Background(), layerPath(&info, id)) | ||||
| } | ||||
| func PrepareLayer(info DriverInfo, layerId string, parentLayerPaths []string) error { | ||||
| 	return wclayer.PrepareLayer(layerPath(&info, layerId), parentLayerPaths) | ||||
| 	return wclayer.PrepareLayer(context.Background(), layerPath(&info, layerId), parentLayerPaths) | ||||
| } | ||||
| func ProcessBaseLayer(path string) error { | ||||
| 	return wclayer.ProcessBaseLayer(path) | ||||
| 	return wclayer.ProcessBaseLayer(context.Background(), path) | ||||
| } | ||||
| func ProcessUtilityVMImage(path string) error { | ||||
| 	return wclayer.ProcessUtilityVMImage(path) | ||||
| 	return wclayer.ProcessUtilityVMImage(context.Background(), path) | ||||
| } | ||||
| func UnprepareLayer(info DriverInfo, layerId string) error { | ||||
| 	return wclayer.UnprepareLayer(layerPath(&info, layerId)) | ||||
| 	return wclayer.UnprepareLayer(context.Background(), layerPath(&info, layerId)) | ||||
| } | ||||
|  | ||||
| type DriverInfo struct { | ||||
| @@ -76,7 +77,7 @@ type DriverInfo struct { | ||||
| type GUID [16]byte | ||||
|  | ||||
| func NameToGuid(name string) (id GUID, err error) { | ||||
| 	g, err := wclayer.NameToGuid(name) | ||||
| 	g, err := wclayer.NameToGuid(context.Background(), name) | ||||
| 	return g.ToWindowsArray(), err | ||||
| } | ||||
|  | ||||
| @@ -94,13 +95,13 @@ func (g *GUID) ToString() string { | ||||
| type LayerReader = wclayer.LayerReader | ||||
|  | ||||
| func NewLayerReader(info DriverInfo, layerID string, parentLayerPaths []string) (LayerReader, error) { | ||||
| 	return wclayer.NewLayerReader(layerPath(&info, layerID), parentLayerPaths) | ||||
| 	return wclayer.NewLayerReader(context.Background(), layerPath(&info, layerID), parentLayerPaths) | ||||
| } | ||||
|  | ||||
| type LayerWriter = wclayer.LayerWriter | ||||
|  | ||||
| func NewLayerWriter(info DriverInfo, layerID string, parentLayerPaths []string) (LayerWriter, error) { | ||||
| 	return wclayer.NewLayerWriter(layerPath(&info, layerID), parentLayerPaths) | ||||
| 	return wclayer.NewLayerWriter(context.Background(), layerPath(&info, layerID), parentLayerPaths) | ||||
| } | ||||
|  | ||||
| type WC_LAYER_DESCRIPTOR = wclayer.WC_LAYER_DESCRIPTOR | ||||
|   | ||||
							
								
								
									
										8
									
								
								vendor/github.com/cespare/xxhash/v2/.travis.yml
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								vendor/github.com/cespare/xxhash/v2/.travis.yml
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| language: go | ||||
| go: | ||||
|   - "1.x" | ||||
|   - master | ||||
| env: | ||||
|   - TAGS="" | ||||
|   - TAGS="-tags purego" | ||||
| script: go test $TAGS -v ./... | ||||
							
								
								
									
										22
									
								
								vendor/github.com/cespare/xxhash/v2/LICENSE.txt
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								vendor/github.com/cespare/xxhash/v2/LICENSE.txt
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| Copyright (c) 2016 Caleb Spare | ||||
|  | ||||
| MIT License | ||||
|  | ||||
| Permission is hereby granted, free of charge, to any person obtaining | ||||
| a copy of this software and associated documentation files (the | ||||
| "Software"), to deal in the Software without restriction, including | ||||
| without limitation the rights to use, copy, modify, merge, publish, | ||||
| distribute, sublicense, and/or sell copies of the Software, and to | ||||
| permit persons to whom the Software is furnished to do so, subject to | ||||
| the following conditions: | ||||
|  | ||||
| The above copyright notice and this permission notice shall be | ||||
| included in all copies or substantial portions of the Software. | ||||
|  | ||||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||||
| EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||||
| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||||
| NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||||
| LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||||
| OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||||
| WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||||
							
								
								
									
										67
									
								
								vendor/github.com/cespare/xxhash/v2/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								vendor/github.com/cespare/xxhash/v2/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,67 @@ | ||||
| # xxhash | ||||
|  | ||||
| [](https://godoc.org/github.com/cespare/xxhash) | ||||
| [](https://travis-ci.org/cespare/xxhash) | ||||
|  | ||||
| xxhash is a Go implementation of the 64-bit | ||||
| [xxHash](http://cyan4973.github.io/xxHash/) algorithm, XXH64. This is a | ||||
| high-quality hashing algorithm that is much faster than anything in the Go | ||||
| standard library. | ||||
|  | ||||
| This package provides a straightforward API: | ||||
|  | ||||
| ``` | ||||
| func Sum64(b []byte) uint64 | ||||
| func Sum64String(s string) uint64 | ||||
| type Digest struct{ ... } | ||||
|     func New() *Digest | ||||
| ``` | ||||
|  | ||||
| The `Digest` type implements hash.Hash64. Its key methods are: | ||||
|  | ||||
| ``` | ||||
| func (*Digest) Write([]byte) (int, error) | ||||
| func (*Digest) WriteString(string) (int, error) | ||||
| func (*Digest) Sum64() uint64 | ||||
| ``` | ||||
|  | ||||
| This implementation provides a fast pure-Go implementation and an even faster | ||||
| assembly implementation for amd64. | ||||
|  | ||||
| ## Compatibility | ||||
|  | ||||
| This package is in a module and the latest code is in version 2 of the module. | ||||
| You need a version of Go with at least "minimal module compatibility" to use | ||||
| github.com/cespare/xxhash/v2: | ||||
|  | ||||
| * 1.9.7+ for Go 1.9 | ||||
| * 1.10.3+ for Go 1.10 | ||||
| * Go 1.11 or later | ||||
|  | ||||
| I recommend using the latest release of Go. | ||||
|  | ||||
| ## Benchmarks | ||||
|  | ||||
| Here are some quick benchmarks comparing the pure-Go and assembly | ||||
| implementations of Sum64. | ||||
|  | ||||
| | input size | purego | asm | | ||||
| | --- | --- | --- | | ||||
| | 5 B   |  979.66 MB/s |  1291.17 MB/s  | | ||||
| | 100 B | 7475.26 MB/s | 7973.40 MB/s  | | ||||
| | 4 KB  | 17573.46 MB/s | 17602.65 MB/s | | ||||
| | 10 MB | 17131.46 MB/s | 17142.16 MB/s | | ||||
|  | ||||
| These numbers were generated on Ubuntu 18.04 with an Intel i7-8700K CPU using | ||||
| the following commands under Go 1.11.2: | ||||
|  | ||||
| ``` | ||||
| $ go test -tags purego -benchtime 10s -bench '/xxhash,direct,bytes' | ||||
| $ go test -benchtime 10s -bench '/xxhash,direct,bytes' | ||||
| ``` | ||||
|  | ||||
| ## Projects using this package | ||||
|  | ||||
| - [InfluxDB](https://github.com/influxdata/influxdb) | ||||
| - [Prometheus](https://github.com/prometheus/prometheus) | ||||
| - [FreeCache](https://github.com/coocood/freecache) | ||||
							
								
								
									
										3
									
								
								vendor/github.com/cespare/xxhash/v2/go.mod
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								vendor/github.com/cespare/xxhash/v2/go.mod
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| module github.com/cespare/xxhash/v2 | ||||
|  | ||||
| go 1.11 | ||||
							
								
								
									
										0
									
								
								vendor/github.com/cespare/xxhash/v2/go.sum
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								vendor/github.com/cespare/xxhash/v2/go.sum
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
								
								
									
										236
									
								
								vendor/github.com/cespare/xxhash/v2/xxhash.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										236
									
								
								vendor/github.com/cespare/xxhash/v2/xxhash.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,236 @@ | ||||
| // Package xxhash implements the 64-bit variant of xxHash (XXH64) as described | ||||
| // at http://cyan4973.github.io/xxHash/. | ||||
| package xxhash | ||||
|  | ||||
| import ( | ||||
| 	"encoding/binary" | ||||
| 	"errors" | ||||
| 	"math/bits" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| 	prime1 uint64 = 11400714785074694791 | ||||
| 	prime2 uint64 = 14029467366897019727 | ||||
| 	prime3 uint64 = 1609587929392839161 | ||||
| 	prime4 uint64 = 9650029242287828579 | ||||
| 	prime5 uint64 = 2870177450012600261 | ||||
| ) | ||||
|  | ||||
| // NOTE(caleb): I'm using both consts and vars of the primes. Using consts where | ||||
| // possible in the Go code is worth a small (but measurable) performance boost | ||||
| // by avoiding some MOVQs. Vars are needed for the asm and also are useful for | ||||
| // convenience in the Go code in a few places where we need to intentionally | ||||
| // avoid constant arithmetic (e.g., v1 := prime1 + prime2 fails because the | ||||
| // result overflows a uint64). | ||||
| var ( | ||||
| 	prime1v = prime1 | ||||
| 	prime2v = prime2 | ||||
| 	prime3v = prime3 | ||||
| 	prime4v = prime4 | ||||
| 	prime5v = prime5 | ||||
| ) | ||||
|  | ||||
| // Digest implements hash.Hash64. | ||||
| type Digest struct { | ||||
| 	v1    uint64 | ||||
| 	v2    uint64 | ||||
| 	v3    uint64 | ||||
| 	v4    uint64 | ||||
| 	total uint64 | ||||
| 	mem   [32]byte | ||||
| 	n     int // how much of mem is used | ||||
| } | ||||
|  | ||||
| // New creates a new Digest that computes the 64-bit xxHash algorithm. | ||||
| func New() *Digest { | ||||
| 	var d Digest | ||||
| 	d.Reset() | ||||
| 	return &d | ||||
| } | ||||
|  | ||||
| // Reset clears the Digest's state so that it can be reused. | ||||
| func (d *Digest) Reset() { | ||||
| 	d.v1 = prime1v + prime2 | ||||
| 	d.v2 = prime2 | ||||
| 	d.v3 = 0 | ||||
| 	d.v4 = -prime1v | ||||
| 	d.total = 0 | ||||
| 	d.n = 0 | ||||
| } | ||||
|  | ||||
| // Size always returns 8 bytes. | ||||
| func (d *Digest) Size() int { return 8 } | ||||
|  | ||||
| // BlockSize always returns 32 bytes. | ||||
| func (d *Digest) BlockSize() int { return 32 } | ||||
|  | ||||
| // Write adds more data to d. It always returns len(b), nil. | ||||
| func (d *Digest) Write(b []byte) (n int, err error) { | ||||
| 	n = len(b) | ||||
| 	d.total += uint64(n) | ||||
|  | ||||
| 	if d.n+n < 32 { | ||||
| 		// This new data doesn't even fill the current block. | ||||
| 		copy(d.mem[d.n:], b) | ||||
| 		d.n += n | ||||
| 		return | ||||
| 	} | ||||
|  | ||||
| 	if d.n > 0 { | ||||
| 		// Finish off the partial block. | ||||
| 		copy(d.mem[d.n:], b) | ||||
| 		d.v1 = round(d.v1, u64(d.mem[0:8])) | ||||
| 		d.v2 = round(d.v2, u64(d.mem[8:16])) | ||||
| 		d.v3 = round(d.v3, u64(d.mem[16:24])) | ||||
| 		d.v4 = round(d.v4, u64(d.mem[24:32])) | ||||
| 		b = b[32-d.n:] | ||||
| 		d.n = 0 | ||||
| 	} | ||||
|  | ||||
| 	if len(b) >= 32 { | ||||
| 		// One or more full blocks left. | ||||
| 		nw := writeBlocks(d, b) | ||||
| 		b = b[nw:] | ||||
| 	} | ||||
|  | ||||
| 	// Store any remaining partial block. | ||||
| 	copy(d.mem[:], b) | ||||
| 	d.n = len(b) | ||||
|  | ||||
| 	return | ||||
| } | ||||
|  | ||||
| // Sum appends the current hash to b and returns the resulting slice. | ||||
| func (d *Digest) Sum(b []byte) []byte { | ||||
| 	s := d.Sum64() | ||||
| 	return append( | ||||
| 		b, | ||||
| 		byte(s>>56), | ||||
| 		byte(s>>48), | ||||
| 		byte(s>>40), | ||||
| 		byte(s>>32), | ||||
| 		byte(s>>24), | ||||
| 		byte(s>>16), | ||||
| 		byte(s>>8), | ||||
| 		byte(s), | ||||
| 	) | ||||
| } | ||||
|  | ||||
| // Sum64 returns the current hash. | ||||
| func (d *Digest) Sum64() uint64 { | ||||
| 	var h uint64 | ||||
|  | ||||
| 	if d.total >= 32 { | ||||
| 		v1, v2, v3, v4 := d.v1, d.v2, d.v3, d.v4 | ||||
| 		h = rol1(v1) + rol7(v2) + rol12(v3) + rol18(v4) | ||||
| 		h = mergeRound(h, v1) | ||||
| 		h = mergeRound(h, v2) | ||||
| 		h = mergeRound(h, v3) | ||||
| 		h = mergeRound(h, v4) | ||||
| 	} else { | ||||
| 		h = d.v3 + prime5 | ||||
| 	} | ||||
|  | ||||
| 	h += d.total | ||||
|  | ||||
| 	i, end := 0, d.n | ||||
| 	for ; i+8 <= end; i += 8 { | ||||
| 		k1 := round(0, u64(d.mem[i:i+8])) | ||||
| 		h ^= k1 | ||||
| 		h = rol27(h)*prime1 + prime4 | ||||
| 	} | ||||
| 	if i+4 <= end { | ||||
| 		h ^= uint64(u32(d.mem[i:i+4])) * prime1 | ||||
| 		h = rol23(h)*prime2 + prime3 | ||||
| 		i += 4 | ||||
| 	} | ||||
| 	for i < end { | ||||
| 		h ^= uint64(d.mem[i]) * prime5 | ||||
| 		h = rol11(h) * prime1 | ||||
| 		i++ | ||||
| 	} | ||||
|  | ||||
| 	h ^= h >> 33 | ||||
| 	h *= prime2 | ||||
| 	h ^= h >> 29 | ||||
| 	h *= prime3 | ||||
| 	h ^= h >> 32 | ||||
|  | ||||
| 	return h | ||||
| } | ||||
|  | ||||
| const ( | ||||
| 	magic         = "xxh\x06" | ||||
| 	marshaledSize = len(magic) + 8*5 + 32 | ||||
| ) | ||||
|  | ||||
| // MarshalBinary implements the encoding.BinaryMarshaler interface. | ||||
| func (d *Digest) MarshalBinary() ([]byte, error) { | ||||
| 	b := make([]byte, 0, marshaledSize) | ||||
| 	b = append(b, magic...) | ||||
| 	b = appendUint64(b, d.v1) | ||||
| 	b = appendUint64(b, d.v2) | ||||
| 	b = appendUint64(b, d.v3) | ||||
| 	b = appendUint64(b, d.v4) | ||||
| 	b = appendUint64(b, d.total) | ||||
| 	b = append(b, d.mem[:d.n]...) | ||||
| 	b = b[:len(b)+len(d.mem)-d.n] | ||||
| 	return b, nil | ||||
| } | ||||
|  | ||||
| // UnmarshalBinary implements the encoding.BinaryUnmarshaler interface. | ||||
| func (d *Digest) UnmarshalBinary(b []byte) error { | ||||
| 	if len(b) < len(magic) || string(b[:len(magic)]) != magic { | ||||
| 		return errors.New("xxhash: invalid hash state identifier") | ||||
| 	} | ||||
| 	if len(b) != marshaledSize { | ||||
| 		return errors.New("xxhash: invalid hash state size") | ||||
| 	} | ||||
| 	b = b[len(magic):] | ||||
| 	b, d.v1 = consumeUint64(b) | ||||
| 	b, d.v2 = consumeUint64(b) | ||||
| 	b, d.v3 = consumeUint64(b) | ||||
| 	b, d.v4 = consumeUint64(b) | ||||
| 	b, d.total = consumeUint64(b) | ||||
| 	copy(d.mem[:], b) | ||||
| 	b = b[len(d.mem):] | ||||
| 	d.n = int(d.total % uint64(len(d.mem))) | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func appendUint64(b []byte, x uint64) []byte { | ||||
| 	var a [8]byte | ||||
| 	binary.LittleEndian.PutUint64(a[:], x) | ||||
| 	return append(b, a[:]...) | ||||
| } | ||||
|  | ||||
| func consumeUint64(b []byte) ([]byte, uint64) { | ||||
| 	x := u64(b) | ||||
| 	return b[8:], x | ||||
| } | ||||
|  | ||||
| func u64(b []byte) uint64 { return binary.LittleEndian.Uint64(b) } | ||||
| func u32(b []byte) uint32 { return binary.LittleEndian.Uint32(b) } | ||||
|  | ||||
| func round(acc, input uint64) uint64 { | ||||
| 	acc += input * prime2 | ||||
| 	acc = rol31(acc) | ||||
| 	acc *= prime1 | ||||
| 	return acc | ||||
| } | ||||
|  | ||||
| func mergeRound(acc, val uint64) uint64 { | ||||
| 	val = round(0, val) | ||||
| 	acc ^= val | ||||
| 	acc = acc*prime1 + prime4 | ||||
| 	return acc | ||||
| } | ||||
|  | ||||
| func rol1(x uint64) uint64  { return bits.RotateLeft64(x, 1) } | ||||
| func rol7(x uint64) uint64  { return bits.RotateLeft64(x, 7) } | ||||
| func rol11(x uint64) uint64 { return bits.RotateLeft64(x, 11) } | ||||
| func rol12(x uint64) uint64 { return bits.RotateLeft64(x, 12) } | ||||
| func rol18(x uint64) uint64 { return bits.RotateLeft64(x, 18) } | ||||
| func rol23(x uint64) uint64 { return bits.RotateLeft64(x, 23) } | ||||
| func rol27(x uint64) uint64 { return bits.RotateLeft64(x, 27) } | ||||
| func rol31(x uint64) uint64 { return bits.RotateLeft64(x, 31) } | ||||
							
								
								
									
										13
									
								
								vendor/github.com/cespare/xxhash/v2/xxhash_amd64.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								vendor/github.com/cespare/xxhash/v2/xxhash_amd64.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| // +build !appengine | ||||
| // +build gc | ||||
| // +build !purego | ||||
|  | ||||
| package xxhash | ||||
|  | ||||
| // Sum64 computes the 64-bit xxHash digest of b. | ||||
| // | ||||
| //go:noescape | ||||
| func Sum64(b []byte) uint64 | ||||
|  | ||||
| //go:noescape | ||||
| func writeBlocks(d *Digest, b []byte) int | ||||
							
								
								
									
										215
									
								
								vendor/github.com/cespare/xxhash/v2/xxhash_amd64.s
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										215
									
								
								vendor/github.com/cespare/xxhash/v2/xxhash_amd64.s
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,215 @@ | ||||
| // +build !appengine | ||||
| // +build gc | ||||
| // +build !purego | ||||
|  | ||||
| #include "textflag.h" | ||||
|  | ||||
| // Register allocation: | ||||
| // AX	h | ||||
| // CX	pointer to advance through b | ||||
| // DX	n | ||||
| // BX	loop end | ||||
| // R8	v1, k1 | ||||
| // R9	v2 | ||||
| // R10	v3 | ||||
| // R11	v4 | ||||
| // R12	tmp | ||||
| // R13	prime1v | ||||
| // R14	prime2v | ||||
| // R15	prime4v | ||||
|  | ||||
| // round reads from and advances the buffer pointer in CX. | ||||
| // It assumes that R13 has prime1v and R14 has prime2v. | ||||
| #define round(r) \ | ||||
| 	MOVQ  (CX), R12 \ | ||||
| 	ADDQ  $8, CX    \ | ||||
| 	IMULQ R14, R12  \ | ||||
| 	ADDQ  R12, r    \ | ||||
| 	ROLQ  $31, r    \ | ||||
| 	IMULQ R13, r | ||||
|  | ||||
| // mergeRound applies a merge round on the two registers acc and val. | ||||
| // It assumes that R13 has prime1v, R14 has prime2v, and R15 has prime4v. | ||||
| #define mergeRound(acc, val) \ | ||||
| 	IMULQ R14, val \ | ||||
| 	ROLQ  $31, val \ | ||||
| 	IMULQ R13, val \ | ||||
| 	XORQ  val, acc \ | ||||
| 	IMULQ R13, acc \ | ||||
| 	ADDQ  R15, acc | ||||
|  | ||||
| // func Sum64(b []byte) uint64 | ||||
| TEXT ·Sum64(SB), NOSPLIT, $0-32 | ||||
| 	// Load fixed primes. | ||||
| 	MOVQ ·prime1v(SB), R13 | ||||
| 	MOVQ ·prime2v(SB), R14 | ||||
| 	MOVQ ·prime4v(SB), R15 | ||||
|  | ||||
| 	// Load slice. | ||||
| 	MOVQ b_base+0(FP), CX | ||||
| 	MOVQ b_len+8(FP), DX | ||||
| 	LEAQ (CX)(DX*1), BX | ||||
|  | ||||
| 	// The first loop limit will be len(b)-32. | ||||
| 	SUBQ $32, BX | ||||
|  | ||||
| 	// Check whether we have at least one block. | ||||
| 	CMPQ DX, $32 | ||||
| 	JLT  noBlocks | ||||
|  | ||||
| 	// Set up initial state (v1, v2, v3, v4). | ||||
| 	MOVQ R13, R8 | ||||
| 	ADDQ R14, R8 | ||||
| 	MOVQ R14, R9 | ||||
| 	XORQ R10, R10 | ||||
| 	XORQ R11, R11 | ||||
| 	SUBQ R13, R11 | ||||
|  | ||||
| 	// Loop until CX > BX. | ||||
| blockLoop: | ||||
| 	round(R8) | ||||
| 	round(R9) | ||||
| 	round(R10) | ||||
| 	round(R11) | ||||
|  | ||||
| 	CMPQ CX, BX | ||||
| 	JLE  blockLoop | ||||
|  | ||||
| 	MOVQ R8, AX | ||||
| 	ROLQ $1, AX | ||||
| 	MOVQ R9, R12 | ||||
| 	ROLQ $7, R12 | ||||
| 	ADDQ R12, AX | ||||
| 	MOVQ R10, R12 | ||||
| 	ROLQ $12, R12 | ||||
| 	ADDQ R12, AX | ||||
| 	MOVQ R11, R12 | ||||
| 	ROLQ $18, R12 | ||||
| 	ADDQ R12, AX | ||||
|  | ||||
| 	mergeRound(AX, R8) | ||||
| 	mergeRound(AX, R9) | ||||
| 	mergeRound(AX, R10) | ||||
| 	mergeRound(AX, R11) | ||||
|  | ||||
| 	JMP afterBlocks | ||||
|  | ||||
| noBlocks: | ||||
| 	MOVQ ·prime5v(SB), AX | ||||
|  | ||||
| afterBlocks: | ||||
| 	ADDQ DX, AX | ||||
|  | ||||
| 	// Right now BX has len(b)-32, and we want to loop until CX > len(b)-8. | ||||
| 	ADDQ $24, BX | ||||
|  | ||||
| 	CMPQ CX, BX | ||||
| 	JG   fourByte | ||||
|  | ||||
| wordLoop: | ||||
| 	// Calculate k1. | ||||
| 	MOVQ  (CX), R8 | ||||
| 	ADDQ  $8, CX | ||||
| 	IMULQ R14, R8 | ||||
| 	ROLQ  $31, R8 | ||||
| 	IMULQ R13, R8 | ||||
|  | ||||
| 	XORQ  R8, AX | ||||
| 	ROLQ  $27, AX | ||||
| 	IMULQ R13, AX | ||||
| 	ADDQ  R15, AX | ||||
|  | ||||
| 	CMPQ CX, BX | ||||
| 	JLE  wordLoop | ||||
|  | ||||
| fourByte: | ||||
| 	ADDQ $4, BX | ||||
| 	CMPQ CX, BX | ||||
| 	JG   singles | ||||
|  | ||||
| 	MOVL  (CX), R8 | ||||
| 	ADDQ  $4, CX | ||||
| 	IMULQ R13, R8 | ||||
| 	XORQ  R8, AX | ||||
|  | ||||
| 	ROLQ  $23, AX | ||||
| 	IMULQ R14, AX | ||||
| 	ADDQ  ·prime3v(SB), AX | ||||
|  | ||||
| singles: | ||||
| 	ADDQ $4, BX | ||||
| 	CMPQ CX, BX | ||||
| 	JGE  finalize | ||||
|  | ||||
| singlesLoop: | ||||
| 	MOVBQZX (CX), R12 | ||||
| 	ADDQ    $1, CX | ||||
| 	IMULQ   ·prime5v(SB), R12 | ||||
| 	XORQ    R12, AX | ||||
|  | ||||
| 	ROLQ  $11, AX | ||||
| 	IMULQ R13, AX | ||||
|  | ||||
| 	CMPQ CX, BX | ||||
| 	JL   singlesLoop | ||||
|  | ||||
| finalize: | ||||
| 	MOVQ  AX, R12 | ||||
| 	SHRQ  $33, R12 | ||||
| 	XORQ  R12, AX | ||||
| 	IMULQ R14, AX | ||||
| 	MOVQ  AX, R12 | ||||
| 	SHRQ  $29, R12 | ||||
| 	XORQ  R12, AX | ||||
| 	IMULQ ·prime3v(SB), AX | ||||
| 	MOVQ  AX, R12 | ||||
| 	SHRQ  $32, R12 | ||||
| 	XORQ  R12, AX | ||||
|  | ||||
| 	MOVQ AX, ret+24(FP) | ||||
| 	RET | ||||
|  | ||||
| // writeBlocks uses the same registers as above except that it uses AX to store | ||||
| // the d pointer. | ||||
|  | ||||
| // func writeBlocks(d *Digest, b []byte) int | ||||
| TEXT ·writeBlocks(SB), NOSPLIT, $0-40 | ||||
| 	// Load fixed primes needed for round. | ||||
| 	MOVQ ·prime1v(SB), R13 | ||||
| 	MOVQ ·prime2v(SB), R14 | ||||
|  | ||||
| 	// Load slice. | ||||
| 	MOVQ b_base+8(FP), CX | ||||
| 	MOVQ b_len+16(FP), DX | ||||
| 	LEAQ (CX)(DX*1), BX | ||||
| 	SUBQ $32, BX | ||||
|  | ||||
| 	// Load vN from d. | ||||
| 	MOVQ d+0(FP), AX | ||||
| 	MOVQ 0(AX), R8   // v1 | ||||
| 	MOVQ 8(AX), R9   // v2 | ||||
| 	MOVQ 16(AX), R10 // v3 | ||||
| 	MOVQ 24(AX), R11 // v4 | ||||
|  | ||||
| 	// We don't need to check the loop condition here; this function is | ||||
| 	// always called with at least one block of data to process. | ||||
| blockLoop: | ||||
| 	round(R8) | ||||
| 	round(R9) | ||||
| 	round(R10) | ||||
| 	round(R11) | ||||
|  | ||||
| 	CMPQ CX, BX | ||||
| 	JLE  blockLoop | ||||
|  | ||||
| 	// Copy vN back to d. | ||||
| 	MOVQ R8, 0(AX) | ||||
| 	MOVQ R9, 8(AX) | ||||
| 	MOVQ R10, 16(AX) | ||||
| 	MOVQ R11, 24(AX) | ||||
|  | ||||
| 	// The number of bytes written is CX minus the old base pointer. | ||||
| 	SUBQ b_base+8(FP), CX | ||||
| 	MOVQ CX, ret+32(FP) | ||||
|  | ||||
| 	RET | ||||
							
								
								
									
										76
									
								
								vendor/github.com/cespare/xxhash/v2/xxhash_other.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										76
									
								
								vendor/github.com/cespare/xxhash/v2/xxhash_other.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,76 @@ | ||||
| // +build !amd64 appengine !gc purego | ||||
|  | ||||
| package xxhash | ||||
|  | ||||
| // Sum64 computes the 64-bit xxHash digest of b. | ||||
| func Sum64(b []byte) uint64 { | ||||
| 	// A simpler version would be | ||||
| 	//   d := New() | ||||
| 	//   d.Write(b) | ||||
| 	//   return d.Sum64() | ||||
| 	// but this is faster, particularly for small inputs. | ||||
|  | ||||
| 	n := len(b) | ||||
| 	var h uint64 | ||||
|  | ||||
| 	if n >= 32 { | ||||
| 		v1 := prime1v + prime2 | ||||
| 		v2 := prime2 | ||||
| 		v3 := uint64(0) | ||||
| 		v4 := -prime1v | ||||
| 		for len(b) >= 32 { | ||||
| 			v1 = round(v1, u64(b[0:8:len(b)])) | ||||
| 			v2 = round(v2, u64(b[8:16:len(b)])) | ||||
| 			v3 = round(v3, u64(b[16:24:len(b)])) | ||||
| 			v4 = round(v4, u64(b[24:32:len(b)])) | ||||
| 			b = b[32:len(b):len(b)] | ||||
| 		} | ||||
| 		h = rol1(v1) + rol7(v2) + rol12(v3) + rol18(v4) | ||||
| 		h = mergeRound(h, v1) | ||||
| 		h = mergeRound(h, v2) | ||||
| 		h = mergeRound(h, v3) | ||||
| 		h = mergeRound(h, v4) | ||||
| 	} else { | ||||
| 		h = prime5 | ||||
| 	} | ||||
|  | ||||
| 	h += uint64(n) | ||||
|  | ||||
| 	i, end := 0, len(b) | ||||
| 	for ; i+8 <= end; i += 8 { | ||||
| 		k1 := round(0, u64(b[i:i+8:len(b)])) | ||||
| 		h ^= k1 | ||||
| 		h = rol27(h)*prime1 + prime4 | ||||
| 	} | ||||
| 	if i+4 <= end { | ||||
| 		h ^= uint64(u32(b[i:i+4:len(b)])) * prime1 | ||||
| 		h = rol23(h)*prime2 + prime3 | ||||
| 		i += 4 | ||||
| 	} | ||||
| 	for ; i < end; i++ { | ||||
| 		h ^= uint64(b[i]) * prime5 | ||||
| 		h = rol11(h) * prime1 | ||||
| 	} | ||||
|  | ||||
| 	h ^= h >> 33 | ||||
| 	h *= prime2 | ||||
| 	h ^= h >> 29 | ||||
| 	h *= prime3 | ||||
| 	h ^= h >> 32 | ||||
|  | ||||
| 	return h | ||||
| } | ||||
|  | ||||
| func writeBlocks(d *Digest, b []byte) int { | ||||
| 	v1, v2, v3, v4 := d.v1, d.v2, d.v3, d.v4 | ||||
| 	n := len(b) | ||||
| 	for len(b) >= 32 { | ||||
| 		v1 = round(v1, u64(b[0:8:len(b)])) | ||||
| 		v2 = round(v2, u64(b[8:16:len(b)])) | ||||
| 		v3 = round(v3, u64(b[16:24:len(b)])) | ||||
| 		v4 = round(v4, u64(b[24:32:len(b)])) | ||||
| 		b = b[32:len(b):len(b)] | ||||
| 	} | ||||
| 	d.v1, d.v2, d.v3, d.v4 = v1, v2, v3, v4 | ||||
| 	return n - len(b) | ||||
| } | ||||
							
								
								
									
										15
									
								
								vendor/github.com/cespare/xxhash/v2/xxhash_safe.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								vendor/github.com/cespare/xxhash/v2/xxhash_safe.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,15 @@ | ||||
| // +build appengine | ||||
|  | ||||
| // This file contains the safe implementations of otherwise unsafe-using code. | ||||
|  | ||||
| package xxhash | ||||
|  | ||||
| // Sum64String computes the 64-bit xxHash digest of s. | ||||
| func Sum64String(s string) uint64 { | ||||
| 	return Sum64([]byte(s)) | ||||
| } | ||||
|  | ||||
| // WriteString adds more data to d. It always returns len(s), nil. | ||||
| func (d *Digest) WriteString(s string) (n int, err error) { | ||||
| 	return d.Write([]byte(s)) | ||||
| } | ||||
							
								
								
									
										46
									
								
								vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								vendor/github.com/cespare/xxhash/v2/xxhash_unsafe.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,46 @@ | ||||
| // +build !appengine | ||||
|  | ||||
| // This file encapsulates usage of unsafe. | ||||
| // xxhash_safe.go contains the safe implementations. | ||||
|  | ||||
| package xxhash | ||||
|  | ||||
| import ( | ||||
| 	"reflect" | ||||
| 	"unsafe" | ||||
| ) | ||||
|  | ||||
| // Notes: | ||||
| // | ||||
| // See https://groups.google.com/d/msg/golang-nuts/dcjzJy-bSpw/tcZYBzQqAQAJ | ||||
| // for some discussion about these unsafe conversions. | ||||
| // | ||||
| // In the future it's possible that compiler optimizations will make these | ||||
| // unsafe operations unnecessary: https://golang.org/issue/2205. | ||||
| // | ||||
| // Both of these wrapper functions still incur function call overhead since they | ||||
| // will not be inlined. We could write Go/asm copies of Sum64 and Digest.Write | ||||
| // for strings to squeeze out a bit more speed. Mid-stack inlining should | ||||
| // eventually fix this. | ||||
|  | ||||
| // Sum64String computes the 64-bit xxHash digest of s. | ||||
| // It may be faster than Sum64([]byte(s)) by avoiding a copy. | ||||
| func Sum64String(s string) uint64 { | ||||
| 	var b []byte | ||||
| 	bh := (*reflect.SliceHeader)(unsafe.Pointer(&b)) | ||||
| 	bh.Data = (*reflect.StringHeader)(unsafe.Pointer(&s)).Data | ||||
| 	bh.Len = len(s) | ||||
| 	bh.Cap = len(s) | ||||
| 	return Sum64(b) | ||||
| } | ||||
|  | ||||
| // WriteString adds more data to d. It always returns len(s), nil. | ||||
| // It may be faster than Write([]byte(s)) by avoiding a copy. | ||||
| func (d *Digest) WriteString(s string) (n int, err error) { | ||||
| 	var b []byte | ||||
| 	bh := (*reflect.SliceHeader)(unsafe.Pointer(&b)) | ||||
| 	bh.Data = (*reflect.StringHeader)(unsafe.Pointer(&s)).Data | ||||
| 	bh.Len = len(s) | ||||
| 	bh.Cap = len(s) | ||||
| 	return d.Write(b) | ||||
| } | ||||
							
								
								
									
										39
									
								
								vendor/github.com/containerd/containerd/content/local/store.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										39
									
								
								vendor/github.com/containerd/containerd/content/local/store.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -92,7 +92,11 @@ func NewLabeledStore(root string, ls LabelStore) (content.Store, error) { | ||||
| } | ||||
|  | ||||
| func (s *store) Info(ctx context.Context, dgst digest.Digest) (content.Info, error) { | ||||
| 	p := s.blobPath(dgst) | ||||
| 	p, err := s.blobPath(dgst) | ||||
| 	if err != nil { | ||||
| 		return content.Info{}, errors.Wrapf(err, "calculating blob info path") | ||||
| 	} | ||||
|  | ||||
| 	fi, err := os.Stat(p) | ||||
| 	if err != nil { | ||||
| 		if os.IsNotExist(err) { | ||||
| @@ -123,7 +127,10 @@ func (s *store) info(dgst digest.Digest, fi os.FileInfo, labels map[string]strin | ||||
|  | ||||
| // ReaderAt returns an io.ReaderAt for the blob. | ||||
| func (s *store) ReaderAt(ctx context.Context, desc ocispec.Descriptor) (content.ReaderAt, error) { | ||||
| 	p := s.blobPath(desc.Digest) | ||||
| 	p, err := s.blobPath(desc.Digest) | ||||
| 	if err != nil { | ||||
| 		return nil, errors.Wrapf(err, "calculating blob path for ReaderAt") | ||||
| 	} | ||||
| 	fi, err := os.Stat(p) | ||||
| 	if err != nil { | ||||
| 		if !os.IsNotExist(err) { | ||||
| @@ -150,7 +157,12 @@ func (s *store) ReaderAt(ctx context.Context, desc ocispec.Descriptor) (content. | ||||
| // While this is safe to do concurrently, safe exist-removal logic must hold | ||||
| // some global lock on the store. | ||||
| func (s *store) Delete(ctx context.Context, dgst digest.Digest) error { | ||||
| 	if err := os.RemoveAll(s.blobPath(dgst)); err != nil { | ||||
| 	bp, err := s.blobPath(dgst) | ||||
| 	if err != nil { | ||||
| 		return errors.Wrapf(err, "calculating blob path for delete") | ||||
| 	} | ||||
|  | ||||
| 	if err := os.RemoveAll(bp); err != nil { | ||||
| 		if !os.IsNotExist(err) { | ||||
| 			return err | ||||
| 		} | ||||
| @@ -166,7 +178,11 @@ func (s *store) Update(ctx context.Context, info content.Info, fieldpaths ...str | ||||
| 		return content.Info{}, errors.Wrapf(errdefs.ErrFailedPrecondition, "update not supported on immutable content store") | ||||
| 	} | ||||
|  | ||||
| 	p := s.blobPath(info.Digest) | ||||
| 	p, err := s.blobPath(info.Digest) | ||||
| 	if err != nil { | ||||
| 		return content.Info{}, errors.Wrapf(err, "calculating blob path for update") | ||||
| 	} | ||||
|  | ||||
| 	fi, err := os.Stat(p) | ||||
| 	if err != nil { | ||||
| 		if os.IsNotExist(err) { | ||||
| @@ -512,7 +528,10 @@ func (s *store) writer(ctx context.Context, ref string, total int64, expected di | ||||
| 	// TODO(stevvooe): Need to actually store expected here. We have | ||||
| 	// code in the service that shouldn't be dealing with this. | ||||
| 	if expected != "" { | ||||
| 		p := s.blobPath(expected) | ||||
| 		p, err := s.blobPath(expected) | ||||
| 		if err != nil { | ||||
| 			return nil, errors.Wrap(err, "calculating expected blob path for writer") | ||||
| 		} | ||||
| 		if _, err := os.Stat(p); err == nil { | ||||
| 			return nil, errors.Wrapf(errdefs.ErrAlreadyExists, "content %v", expected) | ||||
| 		} | ||||
| @@ -607,11 +626,17 @@ func (s *store) Abort(ctx context.Context, ref string) error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (s *store) blobPath(dgst digest.Digest) string { | ||||
| 	return filepath.Join(s.root, "blobs", dgst.Algorithm().String(), dgst.Hex()) | ||||
| func (s *store) blobPath(dgst digest.Digest) (string, error) { | ||||
| 	if err := dgst.Validate(); err != nil { | ||||
| 		return "", errors.Wrapf(errdefs.ErrInvalidArgument, "cannot calculate blob path from invalid digest: %v", err) | ||||
| 	} | ||||
|  | ||||
| 	return filepath.Join(s.root, "blobs", dgst.Algorithm().String(), dgst.Hex()), nil | ||||
| } | ||||
|  | ||||
| func (s *store) ingestRoot(ref string) string { | ||||
| 	// we take a digest of the ref to keep the ingest paths constant length. | ||||
| 	// Note that this is not the current or potential digest of incoming content. | ||||
| 	dgst := digest.FromString(ref) | ||||
| 	return filepath.Join(s.root, "ingest", dgst.Hex()) | ||||
| } | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/github.com/containerd/containerd/content/local/writer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/containerd/containerd/content/local/writer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -115,8 +115,8 @@ func (w *writer) Commit(ctx context.Context, size int64, expected digest.Digest, | ||||
| 	} | ||||
|  | ||||
| 	var ( | ||||
| 		ingest = filepath.Join(w.path, "data") | ||||
| 		target = w.s.blobPath(dgst) | ||||
| 		ingest    = filepath.Join(w.path, "data") | ||||
| 		target, _ = w.s.blobPath(dgst) // ignore error because we calculated this dgst | ||||
| 	) | ||||
|  | ||||
| 	// make sure parent directories of blob exist | ||||
|   | ||||
							
								
								
									
										16
									
								
								vendor/github.com/containerd/containerd/errdefs/errors.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										16
									
								
								vendor/github.com/containerd/containerd/errdefs/errors.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -51,43 +51,43 @@ var ( | ||||
|  | ||||
| // IsInvalidArgument returns true if the error is due to an invalid argument | ||||
| func IsInvalidArgument(err error) bool { | ||||
| 	return errors.Cause(err) == ErrInvalidArgument | ||||
| 	return errors.Is(err, ErrInvalidArgument) | ||||
| } | ||||
|  | ||||
| // IsNotFound returns true if the error is due to a missing object | ||||
| func IsNotFound(err error) bool { | ||||
| 	return errors.Cause(err) == ErrNotFound | ||||
| 	return errors.Is(err, ErrNotFound) | ||||
| } | ||||
|  | ||||
| // IsAlreadyExists returns true if the error is due to an already existing | ||||
| // metadata item | ||||
| func IsAlreadyExists(err error) bool { | ||||
| 	return errors.Cause(err) == ErrAlreadyExists | ||||
| 	return errors.Is(err, ErrAlreadyExists) | ||||
| } | ||||
|  | ||||
| // IsFailedPrecondition returns true if an operation could not proceed to the | ||||
| // lack of a particular condition | ||||
| func IsFailedPrecondition(err error) bool { | ||||
| 	return errors.Cause(err) == ErrFailedPrecondition | ||||
| 	return errors.Is(err, ErrFailedPrecondition) | ||||
| } | ||||
|  | ||||
| // IsUnavailable returns true if the error is due to a resource being unavailable | ||||
| func IsUnavailable(err error) bool { | ||||
| 	return errors.Cause(err) == ErrUnavailable | ||||
| 	return errors.Is(err, ErrUnavailable) | ||||
| } | ||||
|  | ||||
| // IsNotImplemented returns true if the error is due to not being implemented | ||||
| func IsNotImplemented(err error) bool { | ||||
| 	return errors.Cause(err) == ErrNotImplemented | ||||
| 	return errors.Is(err, ErrNotImplemented) | ||||
| } | ||||
|  | ||||
| // IsCanceled returns true if the error is due to `context.Canceled`. | ||||
| func IsCanceled(err error) bool { | ||||
| 	return errors.Cause(err) == context.Canceled | ||||
| 	return errors.Is(err, context.Canceled) | ||||
| } | ||||
|  | ||||
| // IsDeadlineExceeded returns true if the error is due to | ||||
| // `context.DeadlineExceeded`. | ||||
| func IsDeadlineExceeded(err error) bool { | ||||
| 	return errors.Cause(err) == context.DeadlineExceeded | ||||
| 	return errors.Is(err, context.DeadlineExceeded) | ||||
| } | ||||
|   | ||||
							
								
								
									
										47
									
								
								vendor/github.com/containerd/containerd/images/handlers.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										47
									
								
								vendor/github.com/containerd/containerd/images/handlers.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -64,7 +64,7 @@ func Handlers(handlers ...Handler) HandlerFunc { | ||||
| 		for _, handler := range handlers { | ||||
| 			ch, err := handler.Handle(ctx, desc) | ||||
| 			if err != nil { | ||||
| 				if errors.Cause(err) == ErrStopHandler { | ||||
| 				if errors.Is(err, ErrStopHandler) { | ||||
| 					break | ||||
| 				} | ||||
| 				return nil, err | ||||
| @@ -87,7 +87,7 @@ func Walk(ctx context.Context, handler Handler, descs ...ocispec.Descriptor) err | ||||
|  | ||||
| 		children, err := handler.Handle(ctx, desc) | ||||
| 		if err != nil { | ||||
| 			if errors.Cause(err) == ErrSkipDesc { | ||||
| 			if errors.Is(err, ErrSkipDesc) { | ||||
| 				continue // don't traverse the children. | ||||
| 			} | ||||
| 			return err | ||||
| @@ -136,7 +136,7 @@ func Dispatch(ctx context.Context, handler Handler, limiter *semaphore.Weighted, | ||||
| 				limiter.Release(1) | ||||
| 			} | ||||
| 			if err != nil { | ||||
| 				if errors.Cause(err) == ErrSkipDesc { | ||||
| 				if errors.Is(err, ErrSkipDesc) { | ||||
| 					return nil // don't traverse the children. | ||||
| 				} | ||||
| 				return err | ||||
| @@ -170,6 +170,19 @@ func ChildrenHandler(provider content.Provider) HandlerFunc { | ||||
| // the children returned by the handler and passes through the children. | ||||
| // Must follow a handler that returns the children to be labeled. | ||||
| func SetChildrenLabels(manager content.Manager, f HandlerFunc) HandlerFunc { | ||||
| 	return SetChildrenMappedLabels(manager, f, nil) | ||||
| } | ||||
|  | ||||
| // SetChildrenMappedLabels is a handler wrapper which sets labels for the content on | ||||
| // the children returned by the handler and passes through the children. | ||||
| // Must follow a handler that returns the children to be labeled. | ||||
| // The label map allows the caller to control the labels per child descriptor. | ||||
| // For returned labels, the index of the child will be appended to the end | ||||
| // except for the first index when the returned label does not end with '.'. | ||||
| func SetChildrenMappedLabels(manager content.Manager, f HandlerFunc, labelMap func(ocispec.Descriptor) []string) HandlerFunc { | ||||
| 	if labelMap == nil { | ||||
| 		labelMap = ChildGCLabels | ||||
| 	} | ||||
| 	return func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) { | ||||
| 		children, err := f(ctx, desc) | ||||
| 		if err != nil { | ||||
| @@ -177,14 +190,26 @@ func SetChildrenLabels(manager content.Manager, f HandlerFunc) HandlerFunc { | ||||
| 		} | ||||
|  | ||||
| 		if len(children) > 0 { | ||||
| 			info := content.Info{ | ||||
| 				Digest: desc.Digest, | ||||
| 				Labels: map[string]string{}, | ||||
| 			} | ||||
| 			fields := []string{} | ||||
| 			for i, ch := range children { | ||||
| 				info.Labels[fmt.Sprintf("containerd.io/gc.ref.content.%d", i)] = ch.Digest.String() | ||||
| 				fields = append(fields, fmt.Sprintf("labels.containerd.io/gc.ref.content.%d", i)) | ||||
| 			var ( | ||||
| 				info = content.Info{ | ||||
| 					Digest: desc.Digest, | ||||
| 					Labels: map[string]string{}, | ||||
| 				} | ||||
| 				fields = []string{} | ||||
| 				keys   = map[string]uint{} | ||||
| 			) | ||||
| 			for _, ch := range children { | ||||
| 				labelKeys := labelMap(ch) | ||||
| 				for _, key := range labelKeys { | ||||
| 					idx := keys[key] | ||||
| 					keys[key] = idx + 1 | ||||
| 					if idx > 0 || key[len(key)-1] == '.' { | ||||
| 						key = fmt.Sprintf("%s%d", key, idx) | ||||
| 					} | ||||
|  | ||||
| 					info.Labels[key] = ch.Digest.String() | ||||
| 					fields = append(fields, "labels."+key) | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			_, err := manager.Update(ctx, info, fields...) | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/containerd/containerd/images/image.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/containerd/containerd/images/image.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -362,7 +362,7 @@ func Children(ctx context.Context, provider content.Provider, desc ocispec.Descr | ||||
| 			// childless data types. | ||||
| 			return nil, nil | ||||
| 		} | ||||
| 		log.G(ctx).Warnf("encountered unknown type %v; children may not be fetched", desc.MediaType) | ||||
| 		log.G(ctx).Debugf("encountered unknown type %v; children may not be fetched", desc.MediaType) | ||||
| 	} | ||||
|  | ||||
| 	return descs, nil | ||||
|   | ||||
							
								
								
									
										31
									
								
								vendor/github.com/containerd/containerd/images/mediatypes.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										31
									
								
								vendor/github.com/containerd/containerd/images/mediatypes.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -23,6 +23,7 @@ import ( | ||||
|  | ||||
| 	"github.com/containerd/containerd/errdefs" | ||||
| 	ocispec "github.com/opencontainers/image-spec/specs-go/v1" | ||||
| 	"github.com/pkg/errors" | ||||
| ) | ||||
|  | ||||
| // mediatype definitions for image components handled in containerd. | ||||
| @@ -81,7 +82,7 @@ func DiffCompression(ctx context.Context, mediaType string) (string, error) { | ||||
| 		} | ||||
| 		return "", nil | ||||
| 	default: | ||||
| 		return "", errdefs.ErrNotImplemented | ||||
| 		return "", errors.Wrapf(errdefs.ErrNotImplemented, "unrecognised mediatype %s", mediaType) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| @@ -124,3 +125,31 @@ func IsKnownConfig(mt string) bool { | ||||
| 	} | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| // ChildGCLabels returns the label for a given descriptor to reference it | ||||
| func ChildGCLabels(desc ocispec.Descriptor) []string { | ||||
| 	mt := desc.MediaType | ||||
| 	if IsKnownConfig(mt) { | ||||
| 		return []string{"containerd.io/gc.ref.content.config"} | ||||
| 	} | ||||
|  | ||||
| 	switch mt { | ||||
| 	case MediaTypeDockerSchema2Manifest, ocispec.MediaTypeImageManifest: | ||||
| 		return []string{"containerd.io/gc.ref.content.m."} | ||||
| 	} | ||||
|  | ||||
| 	if IsLayerType(mt) { | ||||
| 		return []string{"containerd.io/gc.ref.content.l."} | ||||
| 	} | ||||
|  | ||||
| 	return []string{"containerd.io/gc.ref.content."} | ||||
| } | ||||
|  | ||||
| // ChildGCLabelsFilterLayers returns the labels for a given descriptor to | ||||
| // reference it, skipping layer media types | ||||
| func ChildGCLabelsFilterLayers(desc ocispec.Descriptor) []string { | ||||
| 	if IsLayerType(desc.MediaType) { | ||||
| 		return nil | ||||
| 	} | ||||
| 	return ChildGCLabels(desc) | ||||
| } | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/github.com/containerd/containerd/platforms/cpuinfo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/containerd/containerd/platforms/cpuinfo.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -74,8 +74,8 @@ func getCPUInfo(pattern string) (info string, err error) { | ||||
| } | ||||
|  | ||||
| func getCPUVariant() string { | ||||
| 	if runtime.GOOS == "windows" { | ||||
| 		// Windows only supports v7 for ARM32 and v8 for ARM64 and so we can use | ||||
| 	if runtime.GOOS == "windows" || runtime.GOOS == "darwin" { | ||||
| 		// Windows/Darwin only supports v7 for ARM32 and v8 for ARM64 and so we can use | ||||
| 		// runtime.GOARCH to determine the variants | ||||
| 		var variant string | ||||
| 		switch runtime.GOARCH { | ||||
|   | ||||
							
								
								
									
										206
									
								
								vendor/github.com/containerd/containerd/remotes/docker/auth/fetch.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										206
									
								
								vendor/github.com/containerd/containerd/remotes/docker/auth/fetch.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,206 @@ | ||||
| /* | ||||
|    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 auth | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/json" | ||||
| 	"net/http" | ||||
| 	"net/url" | ||||
| 	"strings" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/containerd/containerd/log" | ||||
| 	remoteserrors "github.com/containerd/containerd/remotes/errors" | ||||
| 	"github.com/pkg/errors" | ||||
| 	"golang.org/x/net/context/ctxhttp" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	// ErrNoToken is returned if a request is successful but the body does not | ||||
| 	// contain an authorization token. | ||||
| 	ErrNoToken = errors.New("authorization server did not include a token in the response") | ||||
| ) | ||||
|  | ||||
| // GenerateTokenOptions generates options for fetching a token based on a challenge | ||||
| func GenerateTokenOptions(ctx context.Context, host, username, secret string, c Challenge) (TokenOptions, error) { | ||||
| 	realm, ok := c.Parameters["realm"] | ||||
| 	if !ok { | ||||
| 		return TokenOptions{}, errors.New("no realm specified for token auth challenge") | ||||
| 	} | ||||
|  | ||||
| 	realmURL, err := url.Parse(realm) | ||||
| 	if err != nil { | ||||
| 		return TokenOptions{}, errors.Wrap(err, "invalid token auth challenge realm") | ||||
| 	} | ||||
|  | ||||
| 	to := TokenOptions{ | ||||
| 		Realm:    realmURL.String(), | ||||
| 		Service:  c.Parameters["service"], | ||||
| 		Username: username, | ||||
| 		Secret:   secret, | ||||
| 	} | ||||
|  | ||||
| 	scope, ok := c.Parameters["scope"] | ||||
| 	if ok { | ||||
| 		to.Scopes = append(to.Scopes, scope) | ||||
| 	} else { | ||||
| 		log.G(ctx).WithField("host", host).Debug("no scope specified for token auth challenge") | ||||
| 	} | ||||
|  | ||||
| 	return to, nil | ||||
| } | ||||
|  | ||||
| // TokenOptions are optios for requesting a token | ||||
| type TokenOptions struct { | ||||
| 	Realm    string | ||||
| 	Service  string | ||||
| 	Scopes   []string | ||||
| 	Username string | ||||
| 	Secret   string | ||||
| } | ||||
|  | ||||
| // OAuthTokenResponse is response from fetching token with a OAuth POST request | ||||
| type OAuthTokenResponse struct { | ||||
| 	AccessToken  string    `json:"access_token"` | ||||
| 	RefreshToken string    `json:"refresh_token"` | ||||
| 	ExpiresIn    int       `json:"expires_in"` | ||||
| 	IssuedAt     time.Time `json:"issued_at"` | ||||
| 	Scope        string    `json:"scope"` | ||||
| } | ||||
|  | ||||
| // FetchTokenWithOAuth fetches a token using a POST request | ||||
| func FetchTokenWithOAuth(ctx context.Context, client *http.Client, headers http.Header, clientID string, to TokenOptions) (*OAuthTokenResponse, error) { | ||||
| 	form := url.Values{} | ||||
| 	if len(to.Scopes) > 0 { | ||||
| 		form.Set("scope", strings.Join(to.Scopes, " ")) | ||||
| 	} | ||||
| 	form.Set("service", to.Service) | ||||
| 	form.Set("client_id", clientID) | ||||
|  | ||||
| 	if to.Username == "" { | ||||
| 		form.Set("grant_type", "refresh_token") | ||||
| 		form.Set("refresh_token", to.Secret) | ||||
| 	} else { | ||||
| 		form.Set("grant_type", "password") | ||||
| 		form.Set("username", to.Username) | ||||
| 		form.Set("password", to.Secret) | ||||
| 	} | ||||
|  | ||||
| 	req, err := http.NewRequest("POST", to.Realm, strings.NewReader(form.Encode())) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	req.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8") | ||||
| 	if headers != nil { | ||||
| 		for k, v := range headers { | ||||
| 			req.Header[k] = append(req.Header[k], v...) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	resp, err := ctxhttp.Do(ctx, client, req) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	defer resp.Body.Close() | ||||
|  | ||||
| 	if resp.StatusCode < 200 || resp.StatusCode >= 400 { | ||||
| 		return nil, errors.WithStack(remoteserrors.NewUnexpectedStatusErr(resp)) | ||||
| 	} | ||||
|  | ||||
| 	decoder := json.NewDecoder(resp.Body) | ||||
|  | ||||
| 	var tr OAuthTokenResponse | ||||
| 	if err = decoder.Decode(&tr); err != nil { | ||||
| 		return nil, errors.Wrap(err, "unable to decode token response") | ||||
| 	} | ||||
|  | ||||
| 	if tr.AccessToken == "" { | ||||
| 		return nil, errors.WithStack(ErrNoToken) | ||||
| 	} | ||||
|  | ||||
| 	return &tr, nil | ||||
| } | ||||
|  | ||||
| // FetchTokenResponse is response from fetching token with GET request | ||||
| type FetchTokenResponse struct { | ||||
| 	Token        string    `json:"token"` | ||||
| 	AccessToken  string    `json:"access_token"` | ||||
| 	ExpiresIn    int       `json:"expires_in"` | ||||
| 	IssuedAt     time.Time `json:"issued_at"` | ||||
| 	RefreshToken string    `json:"refresh_token"` | ||||
| } | ||||
|  | ||||
| // FetchToken fetches a token using a GET request | ||||
| func FetchToken(ctx context.Context, client *http.Client, headers http.Header, to TokenOptions) (*FetchTokenResponse, error) { | ||||
| 	req, err := http.NewRequest("GET", to.Realm, nil) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	if headers != nil { | ||||
| 		for k, v := range headers { | ||||
| 			req.Header[k] = append(req.Header[k], v...) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	reqParams := req.URL.Query() | ||||
|  | ||||
| 	if to.Service != "" { | ||||
| 		reqParams.Add("service", to.Service) | ||||
| 	} | ||||
|  | ||||
| 	for _, scope := range to.Scopes { | ||||
| 		reqParams.Add("scope", scope) | ||||
| 	} | ||||
|  | ||||
| 	if to.Secret != "" { | ||||
| 		req.SetBasicAuth(to.Username, to.Secret) | ||||
| 	} | ||||
|  | ||||
| 	req.URL.RawQuery = reqParams.Encode() | ||||
|  | ||||
| 	resp, err := ctxhttp.Do(ctx, client, req) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	defer resp.Body.Close() | ||||
|  | ||||
| 	if resp.StatusCode < 200 || resp.StatusCode >= 400 { | ||||
| 		return nil, errors.WithStack(remoteserrors.NewUnexpectedStatusErr(resp)) | ||||
| 	} | ||||
|  | ||||
| 	decoder := json.NewDecoder(resp.Body) | ||||
|  | ||||
| 	var tr FetchTokenResponse | ||||
| 	if err = decoder.Decode(&tr); err != nil { | ||||
| 		return nil, errors.Wrap(err, "unable to decode token response") | ||||
| 	} | ||||
|  | ||||
| 	// `access_token` is equivalent to `token` and if both are specified | ||||
| 	// the choice is undefined.  Canonicalize `access_token` by sticking | ||||
| 	// things in `token`. | ||||
| 	if tr.AccessToken != "" { | ||||
| 		tr.Token = tr.AccessToken | ||||
| 	} | ||||
|  | ||||
| 	if tr.Token == "" { | ||||
| 		return nil, errors.WithStack(ErrNoToken) | ||||
| 	} | ||||
|  | ||||
| 	return &tr, nil | ||||
| } | ||||
| @@ -14,7 +14,7 @@ | ||||
|    limitations under the License. | ||||
| */ | ||||
| 
 | ||||
| package docker | ||||
| package auth | ||||
| 
 | ||||
| import ( | ||||
| 	"net/http" | ||||
| @@ -22,31 +22,35 @@ import ( | ||||
| 	"strings" | ||||
| ) | ||||
| 
 | ||||
| type authenticationScheme byte | ||||
| // AuthenticationScheme defines scheme of the authentication method | ||||
| type AuthenticationScheme byte | ||||
| 
 | ||||
| const ( | ||||
| 	basicAuth  authenticationScheme = 1 << iota // Defined in RFC 7617 | ||||
| 	digestAuth                                  // Defined in RFC 7616 | ||||
| 	bearerAuth                                  // Defined in RFC 6750 | ||||
| 	// BasicAuth is scheme for Basic HTTP Authentication RFC 7617 | ||||
| 	BasicAuth AuthenticationScheme = 1 << iota | ||||
| 	// DigestAuth is scheme for HTTP Digest Access Authentication RFC 7616 | ||||
| 	DigestAuth | ||||
| 	// BearerAuth is scheme for OAuth 2.0 Bearer Tokens RFC 6750 | ||||
| 	BearerAuth | ||||
| ) | ||||
| 
 | ||||
| // challenge carries information from a WWW-Authenticate response header. | ||||
| // Challenge carries information from a WWW-Authenticate response header. | ||||
| // See RFC 2617. | ||||
| type challenge struct { | ||||
| type Challenge struct { | ||||
| 	// scheme is the auth-scheme according to RFC 2617 | ||||
| 	scheme authenticationScheme | ||||
| 	Scheme AuthenticationScheme | ||||
| 
 | ||||
| 	// parameters are the auth-params according to RFC 2617 | ||||
| 	parameters map[string]string | ||||
| 	Parameters map[string]string | ||||
| } | ||||
| 
 | ||||
| type byScheme []challenge | ||||
| type byScheme []Challenge | ||||
| 
 | ||||
| func (bs byScheme) Len() int      { return len(bs) } | ||||
| func (bs byScheme) Swap(i, j int) { bs[i], bs[j] = bs[j], bs[i] } | ||||
| 
 | ||||
| // Sort in priority order: token > digest > basic | ||||
| func (bs byScheme) Less(i, j int) bool { return bs[i].scheme > bs[j].scheme } | ||||
| func (bs byScheme) Less(i, j int) bool { return bs[i].Scheme > bs[j].Scheme } | ||||
| 
 | ||||
| // Octet types from RFC 2616. | ||||
| type octetType byte | ||||
| @@ -90,22 +94,23 @@ func init() { | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func parseAuthHeader(header http.Header) []challenge { | ||||
| 	challenges := []challenge{} | ||||
| // ParseAuthHeader parses challenges from WWW-Authenticate header | ||||
| func ParseAuthHeader(header http.Header) []Challenge { | ||||
| 	challenges := []Challenge{} | ||||
| 	for _, h := range header[http.CanonicalHeaderKey("WWW-Authenticate")] { | ||||
| 		v, p := parseValueAndParams(h) | ||||
| 		var s authenticationScheme | ||||
| 		var s AuthenticationScheme | ||||
| 		switch v { | ||||
| 		case "basic": | ||||
| 			s = basicAuth | ||||
| 			s = BasicAuth | ||||
| 		case "digest": | ||||
| 			s = digestAuth | ||||
| 			s = DigestAuth | ||||
| 		case "bearer": | ||||
| 			s = bearerAuth | ||||
| 			s = BearerAuth | ||||
| 		default: | ||||
| 			continue | ||||
| 		} | ||||
| 		challenges = append(challenges, challenge{scheme: s, parameters: p}) | ||||
| 		challenges = append(challenges, Challenge{Scheme: s, Parameters: p}) | ||||
| 	} | ||||
| 	sort.Stable(byScheme(challenges)) | ||||
| 	return challenges | ||||
							
								
								
									
										285
									
								
								vendor/github.com/containerd/containerd/remotes/docker/authorizer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										285
									
								
								vendor/github.com/containerd/containerd/remotes/docker/authorizer.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -19,21 +19,17 @@ package docker | ||||
| import ( | ||||
| 	"context" | ||||
| 	"encoding/base64" | ||||
| 	"encoding/json" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"io/ioutil" | ||||
| 	"net/http" | ||||
| 	"net/url" | ||||
| 	"strings" | ||||
| 	"sync" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/containerd/containerd/errdefs" | ||||
| 	"github.com/containerd/containerd/log" | ||||
| 	"github.com/containerd/containerd/remotes/docker/auth" | ||||
| 	remoteerrors "github.com/containerd/containerd/remotes/errors" | ||||
| 	"github.com/pkg/errors" | ||||
| 	"github.com/sirupsen/logrus" | ||||
| 	"golang.org/x/net/context/ctxhttp" | ||||
| ) | ||||
|  | ||||
| type dockerAuthorizer struct { | ||||
| @@ -135,8 +131,8 @@ func (a *dockerAuthorizer) AddResponses(ctx context.Context, responses []*http.R | ||||
|  | ||||
| 	a.mu.Lock() | ||||
| 	defer a.mu.Unlock() | ||||
| 	for _, c := range parseAuthHeader(last.Header) { | ||||
| 		if c.scheme == bearerAuth { | ||||
| 	for _, c := range auth.ParseAuthHeader(last.Header) { | ||||
| 		if c.Scheme == auth.BearerAuth { | ||||
| 			if err := invalidAuthorization(c, responses); err != nil { | ||||
| 				delete(a.handlers, host) | ||||
| 				return err | ||||
| @@ -152,26 +148,35 @@ func (a *dockerAuthorizer) AddResponses(ctx context.Context, responses []*http.R | ||||
| 				return nil | ||||
| 			} | ||||
|  | ||||
| 			common, err := a.generateTokenOptions(ctx, host, c) | ||||
| 			var username, secret string | ||||
| 			if a.credentials != nil { | ||||
| 				var err error | ||||
| 				username, secret, err = a.credentials(host) | ||||
| 				if err != nil { | ||||
| 					return err | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
| 			common, err := auth.GenerateTokenOptions(ctx, host, username, secret, c) | ||||
| 			if err != nil { | ||||
| 				return err | ||||
| 			} | ||||
|  | ||||
| 			a.handlers[host] = newAuthHandler(a.client, a.header, c.scheme, common) | ||||
| 			a.handlers[host] = newAuthHandler(a.client, a.header, c.Scheme, common) | ||||
| 			return nil | ||||
| 		} else if c.scheme == basicAuth && a.credentials != nil { | ||||
| 		} else if c.Scheme == auth.BasicAuth && a.credentials != nil { | ||||
| 			username, secret, err := a.credentials(host) | ||||
| 			if err != nil { | ||||
| 				return err | ||||
| 			} | ||||
|  | ||||
| 			if username != "" && secret != "" { | ||||
| 				common := tokenOptions{ | ||||
| 					username: username, | ||||
| 					secret:   secret, | ||||
| 				common := auth.TokenOptions{ | ||||
| 					Username: username, | ||||
| 					Secret:   secret, | ||||
| 				} | ||||
|  | ||||
| 				a.handlers[host] = newAuthHandler(a.client, a.header, c.scheme, common) | ||||
| 				a.handlers[host] = newAuthHandler(a.client, a.header, c.Scheme, common) | ||||
| 				return nil | ||||
| 			} | ||||
| 		} | ||||
| @@ -179,38 +184,6 @@ func (a *dockerAuthorizer) AddResponses(ctx context.Context, responses []*http.R | ||||
| 	return errors.Wrap(errdefs.ErrNotImplemented, "failed to find supported auth scheme") | ||||
| } | ||||
|  | ||||
| func (a *dockerAuthorizer) generateTokenOptions(ctx context.Context, host string, c challenge) (tokenOptions, error) { | ||||
| 	realm, ok := c.parameters["realm"] | ||||
| 	if !ok { | ||||
| 		return tokenOptions{}, errors.New("no realm specified for token auth challenge") | ||||
| 	} | ||||
|  | ||||
| 	realmURL, err := url.Parse(realm) | ||||
| 	if err != nil { | ||||
| 		return tokenOptions{}, errors.Wrap(err, "invalid token auth challenge realm") | ||||
| 	} | ||||
|  | ||||
| 	to := tokenOptions{ | ||||
| 		realm:   realmURL.String(), | ||||
| 		service: c.parameters["service"], | ||||
| 	} | ||||
|  | ||||
| 	scope, ok := c.parameters["scope"] | ||||
| 	if ok { | ||||
| 		to.scopes = append(to.scopes, scope) | ||||
| 	} else { | ||||
| 		log.G(ctx).WithField("host", host).Debug("no scope specified for token auth challenge") | ||||
| 	} | ||||
|  | ||||
| 	if a.credentials != nil { | ||||
| 		to.username, to.secret, err = a.credentials(host) | ||||
| 		if err != nil { | ||||
| 			return tokenOptions{}, err | ||||
| 		} | ||||
| 	} | ||||
| 	return to, nil | ||||
| } | ||||
|  | ||||
| // authResult is used to control limit rate. | ||||
| type authResult struct { | ||||
| 	sync.WaitGroup | ||||
| @@ -227,17 +200,17 @@ type authHandler struct { | ||||
| 	client *http.Client | ||||
|  | ||||
| 	// only support basic and bearer schemes | ||||
| 	scheme authenticationScheme | ||||
| 	scheme auth.AuthenticationScheme | ||||
|  | ||||
| 	// common contains common challenge answer | ||||
| 	common tokenOptions | ||||
| 	common auth.TokenOptions | ||||
|  | ||||
| 	// scopedTokens caches token indexed by scopes, which used in | ||||
| 	// bearer auth case | ||||
| 	scopedTokens map[string]*authResult | ||||
| } | ||||
|  | ||||
| func newAuthHandler(client *http.Client, hdr http.Header, scheme authenticationScheme, opts tokenOptions) *authHandler { | ||||
| func newAuthHandler(client *http.Client, hdr http.Header, scheme auth.AuthenticationScheme, opts auth.TokenOptions) *authHandler { | ||||
| 	return &authHandler{ | ||||
| 		header:       hdr, | ||||
| 		client:       client, | ||||
| @@ -249,17 +222,17 @@ func newAuthHandler(client *http.Client, hdr http.Header, scheme authenticationS | ||||
|  | ||||
| func (ah *authHandler) authorize(ctx context.Context) (string, error) { | ||||
| 	switch ah.scheme { | ||||
| 	case basicAuth: | ||||
| 	case auth.BasicAuth: | ||||
| 		return ah.doBasicAuth(ctx) | ||||
| 	case bearerAuth: | ||||
| 	case auth.BearerAuth: | ||||
| 		return ah.doBearerAuth(ctx) | ||||
| 	default: | ||||
| 		return "", errors.Wrap(errdefs.ErrNotImplemented, "failed to find supported auth scheme") | ||||
| 		return "", errors.Wrapf(errdefs.ErrNotImplemented, "failed to find supported auth scheme: %s", string(ah.scheme)) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (ah *authHandler) doBasicAuth(ctx context.Context) (string, error) { | ||||
| 	username, secret := ah.common.username, ah.common.secret | ||||
| 	username, secret := ah.common.Username, ah.common.Secret | ||||
|  | ||||
| 	if username == "" || secret == "" { | ||||
| 		return "", fmt.Errorf("failed to handle basic auth because missing username or secret") | ||||
| @@ -269,14 +242,14 @@ func (ah *authHandler) doBasicAuth(ctx context.Context) (string, error) { | ||||
| 	return fmt.Sprintf("Basic %s", auth), nil | ||||
| } | ||||
|  | ||||
| func (ah *authHandler) doBearerAuth(ctx context.Context) (string, error) { | ||||
| func (ah *authHandler) doBearerAuth(ctx context.Context) (token string, err error) { | ||||
| 	// copy common tokenOptions | ||||
| 	to := ah.common | ||||
|  | ||||
| 	to.scopes = getTokenScopes(ctx, to.scopes) | ||||
| 	to.Scopes = GetTokenScopes(ctx, to.Scopes) | ||||
|  | ||||
| 	// Docs: https://docs.docker.com/registry/spec/auth/scope | ||||
| 	scoped := strings.Join(to.scopes, " ") | ||||
| 	scoped := strings.Join(to.Scopes, " ") | ||||
|  | ||||
| 	ah.Lock() | ||||
| 	if r, exist := ah.scopedTokens[scoped]; exist { | ||||
| @@ -291,174 +264,52 @@ func (ah *authHandler) doBearerAuth(ctx context.Context) (string, error) { | ||||
| 	ah.scopedTokens[scoped] = r | ||||
| 	ah.Unlock() | ||||
|  | ||||
| 	defer func() { | ||||
| 		token = fmt.Sprintf("Bearer %s", token) | ||||
| 		r.token, r.err = token, err | ||||
| 		r.Done() | ||||
| 	}() | ||||
|  | ||||
| 	// fetch token for the resource scope | ||||
| 	var ( | ||||
| 		token string | ||||
| 		err   error | ||||
| 	) | ||||
| 	if to.secret != "" { | ||||
| 	if to.Secret != "" { | ||||
| 		defer func() { | ||||
| 			err = errors.Wrap(err, "failed to fetch oauth token") | ||||
| 		}() | ||||
| 		// credential information is provided, use oauth POST endpoint | ||||
| 		token, err = ah.fetchTokenWithOAuth(ctx, to) | ||||
| 		err = errors.Wrap(err, "failed to fetch oauth token") | ||||
| 	} else { | ||||
| 		// do request anonymously | ||||
| 		token, err = ah.fetchToken(ctx, to) | ||||
| 		err = errors.Wrap(err, "failed to fetch anonymous token") | ||||
| 	} | ||||
| 	token = fmt.Sprintf("Bearer %s", token) | ||||
|  | ||||
| 	r.token, r.err = token, err | ||||
| 	r.Done() | ||||
| 	return r.token, r.err | ||||
| } | ||||
|  | ||||
| type tokenOptions struct { | ||||
| 	realm    string | ||||
| 	service  string | ||||
| 	scopes   []string | ||||
| 	username string | ||||
| 	secret   string | ||||
| } | ||||
|  | ||||
| type postTokenResponse struct { | ||||
| 	AccessToken  string    `json:"access_token"` | ||||
| 	RefreshToken string    `json:"refresh_token"` | ||||
| 	ExpiresIn    int       `json:"expires_in"` | ||||
| 	IssuedAt     time.Time `json:"issued_at"` | ||||
| 	Scope        string    `json:"scope"` | ||||
| } | ||||
|  | ||||
| func (ah *authHandler) fetchTokenWithOAuth(ctx context.Context, to tokenOptions) (string, error) { | ||||
| 	form := url.Values{} | ||||
| 	if len(to.scopes) > 0 { | ||||
| 		form.Set("scope", strings.Join(to.scopes, " ")) | ||||
| 	} | ||||
| 	form.Set("service", to.service) | ||||
| 	// TODO: Allow setting client_id | ||||
| 	form.Set("client_id", "containerd-client") | ||||
|  | ||||
| 	if to.username == "" { | ||||
| 		form.Set("grant_type", "refresh_token") | ||||
| 		form.Set("refresh_token", to.secret) | ||||
| 	} else { | ||||
| 		form.Set("grant_type", "password") | ||||
| 		form.Set("username", to.username) | ||||
| 		form.Set("password", to.secret) | ||||
| 	} | ||||
|  | ||||
| 	req, err := http.NewRequest("POST", to.realm, strings.NewReader(form.Encode())) | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
| 	req.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=utf-8") | ||||
| 	if ah.header != nil { | ||||
| 		for k, v := range ah.header { | ||||
| 			req.Header[k] = append(req.Header[k], v...) | ||||
| 		// TODO: Allow setting client_id | ||||
| 		resp, err := auth.FetchTokenWithOAuth(ctx, ah.client, ah.header, "containerd-client", to) | ||||
| 		if err != nil { | ||||
| 			var errStatus remoteerrors.ErrUnexpectedStatus | ||||
| 			if errors.As(err, &errStatus) { | ||||
| 				// Registries without support for POST may return 404 for POST /v2/token. | ||||
| 				// As of September 2017, GCR is known to return 404. | ||||
| 				// As of February 2018, JFrog Artifactory is known to return 401. | ||||
| 				if (errStatus.StatusCode == 405 && to.Username != "") || errStatus.StatusCode == 404 || errStatus.StatusCode == 401 { | ||||
| 					resp, err := auth.FetchToken(ctx, ah.client, ah.header, to) | ||||
| 					if err != nil { | ||||
| 						return "", err | ||||
| 					} | ||||
| 					return resp.Token, nil | ||||
| 				} | ||||
| 				log.G(ctx).WithFields(logrus.Fields{ | ||||
| 					"status": errStatus.Status, | ||||
| 					"body":   string(errStatus.Body), | ||||
| 				}).Debugf("token request failed") | ||||
| 			} | ||||
| 			return "", err | ||||
| 		} | ||||
| 		return resp.AccessToken, nil | ||||
| 	} | ||||
|  | ||||
| 	resp, err := ctxhttp.Do(ctx, ah.client, req) | ||||
| 	// do request anonymously | ||||
| 	resp, err := auth.FetchToken(ctx, ah.client, ah.header, to) | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 		return "", errors.Wrap(err, "failed to fetch anonymous token") | ||||
| 	} | ||||
| 	defer resp.Body.Close() | ||||
|  | ||||
| 	// Registries without support for POST may return 404 for POST /v2/token. | ||||
| 	// As of September 2017, GCR is known to return 404. | ||||
| 	// As of February 2018, JFrog Artifactory is known to return 401. | ||||
| 	if (resp.StatusCode == 405 && to.username != "") || resp.StatusCode == 404 || resp.StatusCode == 401 { | ||||
| 		return ah.fetchToken(ctx, to) | ||||
| 	} else if resp.StatusCode < 200 || resp.StatusCode >= 400 { | ||||
| 		b, _ := ioutil.ReadAll(io.LimitReader(resp.Body, 64000)) // 64KB | ||||
| 		log.G(ctx).WithFields(logrus.Fields{ | ||||
| 			"status": resp.Status, | ||||
| 			"body":   string(b), | ||||
| 		}).Debugf("token request failed") | ||||
| 		// TODO: handle error body and write debug output | ||||
| 		return "", errors.Errorf("unexpected status: %s", resp.Status) | ||||
| 	} | ||||
|  | ||||
| 	decoder := json.NewDecoder(resp.Body) | ||||
|  | ||||
| 	var tr postTokenResponse | ||||
| 	if err = decoder.Decode(&tr); err != nil { | ||||
| 		return "", fmt.Errorf("unable to decode token response: %s", err) | ||||
| 	} | ||||
|  | ||||
| 	return tr.AccessToken, nil | ||||
| 	return resp.Token, nil | ||||
| } | ||||
|  | ||||
| type getTokenResponse struct { | ||||
| 	Token        string    `json:"token"` | ||||
| 	AccessToken  string    `json:"access_token"` | ||||
| 	ExpiresIn    int       `json:"expires_in"` | ||||
| 	IssuedAt     time.Time `json:"issued_at"` | ||||
| 	RefreshToken string    `json:"refresh_token"` | ||||
| } | ||||
|  | ||||
| // fetchToken fetches a token using a GET request | ||||
| func (ah *authHandler) fetchToken(ctx context.Context, to tokenOptions) (string, error) { | ||||
| 	req, err := http.NewRequest("GET", to.realm, nil) | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
|  | ||||
| 	if ah.header != nil { | ||||
| 		for k, v := range ah.header { | ||||
| 			req.Header[k] = append(req.Header[k], v...) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	reqParams := req.URL.Query() | ||||
|  | ||||
| 	if to.service != "" { | ||||
| 		reqParams.Add("service", to.service) | ||||
| 	} | ||||
|  | ||||
| 	for _, scope := range to.scopes { | ||||
| 		reqParams.Add("scope", scope) | ||||
| 	} | ||||
|  | ||||
| 	if to.secret != "" { | ||||
| 		req.SetBasicAuth(to.username, to.secret) | ||||
| 	} | ||||
|  | ||||
| 	req.URL.RawQuery = reqParams.Encode() | ||||
|  | ||||
| 	resp, err := ctxhttp.Do(ctx, ah.client, req) | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
| 	defer resp.Body.Close() | ||||
|  | ||||
| 	if resp.StatusCode < 200 || resp.StatusCode >= 400 { | ||||
| 		// TODO: handle error body and write debug output | ||||
| 		return "", errors.Errorf("unexpected status: %s", resp.Status) | ||||
| 	} | ||||
|  | ||||
| 	decoder := json.NewDecoder(resp.Body) | ||||
|  | ||||
| 	var tr getTokenResponse | ||||
| 	if err = decoder.Decode(&tr); err != nil { | ||||
| 		return "", fmt.Errorf("unable to decode token response: %s", err) | ||||
| 	} | ||||
|  | ||||
| 	// `access_token` is equivalent to `token` and if both are specified | ||||
| 	// the choice is undefined.  Canonicalize `access_token` by sticking | ||||
| 	// things in `token`. | ||||
| 	if tr.AccessToken != "" { | ||||
| 		tr.Token = tr.AccessToken | ||||
| 	} | ||||
|  | ||||
| 	if tr.Token == "" { | ||||
| 		return "", ErrNoToken | ||||
| 	} | ||||
|  | ||||
| 	return tr.Token, nil | ||||
| } | ||||
|  | ||||
| func invalidAuthorization(c challenge, responses []*http.Response) error { | ||||
| 	errStr := c.parameters["error"] | ||||
| func invalidAuthorization(c auth.Challenge, responses []*http.Response) error { | ||||
| 	errStr := c.Parameters["error"] | ||||
| 	if errStr == "" { | ||||
| 		return nil | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										6
									
								
								vendor/github.com/containerd/containerd/remotes/docker/fetcher.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								vendor/github.com/containerd/containerd/remotes/docker/fetcher.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -98,6 +98,9 @@ func (r dockerFetcher) Fetch(ctx context.Context, desc ocispec.Descriptor) (io.R | ||||
| 			var firstErr error | ||||
| 			for _, host := range r.hosts { | ||||
| 				req := r.request(host, http.MethodGet, "manifests", desc.Digest.String()) | ||||
| 				if err := req.addNamespace(r.refspec.Hostname()); err != nil { | ||||
| 					return nil, err | ||||
| 				} | ||||
|  | ||||
| 				rc, err := r.open(ctx, req, desc.MediaType, offset) | ||||
| 				if err != nil { | ||||
| @@ -118,6 +121,9 @@ func (r dockerFetcher) Fetch(ctx context.Context, desc ocispec.Descriptor) (io.R | ||||
| 		var firstErr error | ||||
| 		for _, host := range r.hosts { | ||||
| 			req := r.request(host, http.MethodGet, "blobs", desc.Digest.String()) | ||||
| 			if err := req.addNamespace(r.refspec.Hostname()); err != nil { | ||||
| 				return nil, err | ||||
| 			} | ||||
|  | ||||
| 			rc, err := r.open(ctx, req, desc.MediaType, offset) | ||||
| 			if err != nil { | ||||
|   | ||||
							
								
								
									
										20
									
								
								vendor/github.com/containerd/containerd/remotes/docker/pusher.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								vendor/github.com/containerd/containerd/remotes/docker/pusher.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -30,6 +30,7 @@ import ( | ||||
| 	"github.com/containerd/containerd/images" | ||||
| 	"github.com/containerd/containerd/log" | ||||
| 	"github.com/containerd/containerd/remotes" | ||||
| 	remoteserrors "github.com/containerd/containerd/remotes/errors" | ||||
| 	digest "github.com/opencontainers/go-digest" | ||||
| 	ocispec "github.com/opencontainers/image-spec/specs-go/v1" | ||||
| 	"github.com/pkg/errors" | ||||
| @@ -86,7 +87,7 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten | ||||
|  | ||||
| 	resp, err := req.doWithRetries(ctx, nil) | ||||
| 	if err != nil { | ||||
| 		if errors.Cause(err) != ErrInvalidAuthorization { | ||||
| 		if !errors.Is(err, ErrInvalidAuthorization) { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		log.G(ctx).WithError(err).Debugf("Unable to check existence, continuing with push") | ||||
| @@ -112,8 +113,9 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten | ||||
| 				return nil, errors.Wrapf(errdefs.ErrAlreadyExists, "content %v on remote", desc.Digest) | ||||
| 			} | ||||
| 		} else if resp.StatusCode != http.StatusNotFound { | ||||
| 			// TODO: log error | ||||
| 			return nil, errors.Errorf("unexpected response: %s", resp.Status) | ||||
| 			err := remoteserrors.NewUnexpectedStatusErr(resp) | ||||
| 			log.G(ctx).WithField("resp", resp).WithField("body", string(err.(remoteserrors.ErrUnexpectedStatus).Body)).Debug("unexpected response") | ||||
| 			return nil, err | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -166,8 +168,9 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten | ||||
| 			}) | ||||
| 			return nil, errors.Wrapf(errdefs.ErrAlreadyExists, "content %v on remote", desc.Digest) | ||||
| 		default: | ||||
| 			// TODO: log error | ||||
| 			return nil, errors.Errorf("unexpected response: %s", resp.Status) | ||||
| 			err := remoteserrors.NewUnexpectedStatusErr(resp) | ||||
| 			log.G(ctx).WithField("resp", resp).WithField("body", string(err.(remoteserrors.ErrUnexpectedStatus).Body)).Debug("unexpected response") | ||||
| 			return nil, err | ||||
| 		} | ||||
|  | ||||
| 		var ( | ||||
| @@ -235,7 +238,7 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten | ||||
|  | ||||
| 	go func() { | ||||
| 		defer close(respC) | ||||
| 		resp, err = req.do(ctx) | ||||
| 		resp, err := req.do(ctx) | ||||
| 		if err != nil { | ||||
| 			pr.CloseWithError(err) | ||||
| 			return | ||||
| @@ -244,8 +247,9 @@ func (p dockerPusher) Push(ctx context.Context, desc ocispec.Descriptor) (conten | ||||
| 		switch resp.StatusCode { | ||||
| 		case http.StatusOK, http.StatusCreated, http.StatusNoContent: | ||||
| 		default: | ||||
| 			// TODO: log error | ||||
| 			pr.CloseWithError(errors.Errorf("unexpected response: %s", resp.Status)) | ||||
| 			err := remoteserrors.NewUnexpectedStatusErr(resp) | ||||
| 			log.G(ctx).WithField("resp", resp).WithField("body", string(err.(remoteserrors.ErrUnexpectedStatus).Body)).Debug("unexpected response") | ||||
| 			pr.CloseWithError(err) | ||||
| 		} | ||||
| 		respC <- resp | ||||
| 	}() | ||||
|   | ||||
							
								
								
									
										10
									
								
								vendor/github.com/containerd/containerd/remotes/docker/registry.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								vendor/github.com/containerd/containerd/remotes/docker/registry.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -70,6 +70,16 @@ type RegistryHost struct { | ||||
| 	Scheme       string | ||||
| 	Path         string | ||||
| 	Capabilities HostCapabilities | ||||
| 	Header       http.Header | ||||
| } | ||||
|  | ||||
| func (h RegistryHost) isProxy(refhost string) bool { | ||||
| 	if refhost != h.Host { | ||||
| 		if refhost != "docker.io" || h.Host != "registry-1.docker.io" { | ||||
| 			return true | ||||
| 		} | ||||
| 	} | ||||
| 	return false | ||||
| } | ||||
|  | ||||
| // RegistryHosts fetches the registry hosts for a given namespace, | ||||
|   | ||||
							
								
								
									
										59
									
								
								vendor/github.com/containerd/containerd/remotes/docker/resolver.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										59
									
								
								vendor/github.com/containerd/containerd/remotes/docker/resolver.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -22,6 +22,7 @@ import ( | ||||
| 	"io" | ||||
| 	"io/ioutil" | ||||
| 	"net/http" | ||||
| 	"net/url" | ||||
| 	"path" | ||||
| 	"strings" | ||||
|  | ||||
| @@ -40,10 +41,6 @@ import ( | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	// ErrNoToken is returned if a request is successful but the body does not | ||||
| 	// contain an authorization token. | ||||
| 	ErrNoToken = errors.New("authorization server did not include a token in the response") | ||||
|  | ||||
| 	// ErrInvalidAuthorization is used when credentials are passed to a server but | ||||
| 	// those credentials are rejected. | ||||
| 	ErrInvalidAuthorization = errors.New("authorization failed") | ||||
| @@ -276,6 +273,10 @@ func (r *dockerResolver) Resolve(ctx context.Context, ref string) (string, ocisp | ||||
| 			ctx := log.WithLogger(ctx, log.G(ctx).WithField("host", host.Host)) | ||||
|  | ||||
| 			req := base.request(host, http.MethodHead, u...) | ||||
| 			if err := req.addNamespace(base.refspec.Hostname()); err != nil { | ||||
| 				return "", ocispec.Descriptor{}, err | ||||
| 			} | ||||
|  | ||||
| 			for key, value := range r.resolveHeader { | ||||
| 				req.header[key] = append(req.header[key], value...) | ||||
| 			} | ||||
| @@ -283,7 +284,7 @@ func (r *dockerResolver) Resolve(ctx context.Context, ref string) (string, ocisp | ||||
| 			log.G(ctx).Debug("resolving") | ||||
| 			resp, err := req.doWithRetries(ctx, nil) | ||||
| 			if err != nil { | ||||
| 				if errors.Cause(err) == ErrInvalidAuthorization { | ||||
| 				if errors.Is(err, ErrInvalidAuthorization) { | ||||
| 					err = errors.Wrapf(err, "pull access denied, repository does not exist or may require authorization") | ||||
| 				} | ||||
| 				// Store the error for referencing later | ||||
| @@ -323,6 +324,10 @@ func (r *dockerResolver) Resolve(ctx context.Context, ref string) (string, ocisp | ||||
| 				log.G(ctx).Debug("no Docker-Content-Digest header, fetching manifest instead") | ||||
|  | ||||
| 				req = base.request(host, http.MethodGet, u...) | ||||
| 				if err := req.addNamespace(base.refspec.Hostname()); err != nil { | ||||
| 					return "", ocispec.Descriptor{}, err | ||||
| 				} | ||||
|  | ||||
| 				for key, value := range r.resolveHeader { | ||||
| 					req.header[key] = append(req.header[key], value...) | ||||
| 				} | ||||
| @@ -416,10 +421,10 @@ func (r *dockerResolver) Pusher(ctx context.Context, ref string) (remotes.Pusher | ||||
| } | ||||
|  | ||||
| type dockerBase struct { | ||||
| 	refspec   reference.Spec | ||||
| 	namespace string | ||||
| 	hosts     []RegistryHost | ||||
| 	header    http.Header | ||||
| 	refspec    reference.Spec | ||||
| 	repository string | ||||
| 	hosts      []RegistryHost | ||||
| 	header     http.Header | ||||
| } | ||||
|  | ||||
| func (r *dockerResolver) base(refspec reference.Spec) (*dockerBase, error) { | ||||
| @@ -429,10 +434,10 @@ func (r *dockerResolver) base(refspec reference.Spec) (*dockerBase, error) { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return &dockerBase{ | ||||
| 		refspec:   refspec, | ||||
| 		namespace: strings.TrimPrefix(refspec.Locator, host+"/"), | ||||
| 		hosts:     hosts, | ||||
| 		header:    r.header, | ||||
| 		refspec:    refspec, | ||||
| 		repository: strings.TrimPrefix(refspec.Locator, host+"/"), | ||||
| 		hosts:      hosts, | ||||
| 		header:     r.header, | ||||
| 	}, nil | ||||
| } | ||||
|  | ||||
| @@ -450,7 +455,10 @@ func (r *dockerBase) request(host RegistryHost, method string, ps ...string) *re | ||||
| 	for key, value := range r.header { | ||||
| 		header[key] = append(header[key], value...) | ||||
| 	} | ||||
| 	parts := append([]string{"/", host.Path, r.namespace}, ps...) | ||||
| 	for key, value := range host.Header { | ||||
| 		header[key] = append(header[key], value...) | ||||
| 	} | ||||
| 	parts := append([]string{"/", host.Path, r.repository}, ps...) | ||||
| 	p := path.Join(parts...) | ||||
| 	// Join strips trailing slash, re-add ending "/" if included | ||||
| 	if len(parts) > 0 && strings.HasSuffix(parts[len(parts)-1], "/") { | ||||
| @@ -475,6 +483,29 @@ func (r *request) authorize(ctx context.Context, req *http.Request) error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (r *request) addNamespace(ns string) (err error) { | ||||
| 	if !r.host.isProxy(ns) { | ||||
| 		return nil | ||||
| 	} | ||||
| 	var q url.Values | ||||
| 	// Parse query | ||||
| 	if i := strings.IndexByte(r.path, '?'); i > 0 { | ||||
| 		r.path = r.path[:i+1] | ||||
| 		q, err = url.ParseQuery(r.path[i+1:]) | ||||
| 		if err != nil { | ||||
| 			return | ||||
| 		} | ||||
| 	} else { | ||||
| 		r.path = r.path + "?" | ||||
| 		q = url.Values{} | ||||
| 	} | ||||
| 	q.Add("ns", ns) | ||||
|  | ||||
| 	r.path = r.path + q.Encode() | ||||
|  | ||||
| 	return | ||||
| } | ||||
|  | ||||
| type request struct { | ||||
| 	method string | ||||
| 	path   string | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/github.com/containerd/containerd/remotes/docker/scope.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/containerd/containerd/remotes/docker/scope.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -72,8 +72,8 @@ func contextWithAppendPullRepositoryScope(ctx context.Context, repo string) cont | ||||
| 	return WithScope(ctx, fmt.Sprintf("repository:%s:pull", repo)) | ||||
| } | ||||
|  | ||||
| // getTokenScopes returns deduplicated and sorted scopes from ctx.Value(tokenScopesKey{}) and common scopes. | ||||
| func getTokenScopes(ctx context.Context, common []string) []string { | ||||
| // GetTokenScopes returns deduplicated and sorted scopes from ctx.Value(tokenScopesKey{}) and common scopes. | ||||
| func GetTokenScopes(ctx context.Context, common []string) []string { | ||||
| 	var scopes []string | ||||
| 	if x := ctx.Value(tokenScopesKey{}); x != nil { | ||||
| 		scopes = append(scopes, x.([]string)...) | ||||
|   | ||||
							
								
								
									
										46
									
								
								vendor/github.com/containerd/containerd/remotes/errors/errors.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								vendor/github.com/containerd/containerd/remotes/errors/errors.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,46 @@ | ||||
| /* | ||||
|    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 errors | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"io/ioutil" | ||||
| 	"net/http" | ||||
| ) | ||||
|  | ||||
| var _ error = ErrUnexpectedStatus{} | ||||
|  | ||||
| // ErrUnexpectedStatus is returned if a registry API request returned with unexpected HTTP status | ||||
| type ErrUnexpectedStatus struct { | ||||
| 	Status     string | ||||
| 	StatusCode int | ||||
| 	Body       []byte | ||||
| } | ||||
|  | ||||
| func (e ErrUnexpectedStatus) Error() string { | ||||
| 	return fmt.Sprintf("unexpected status: %s", e.Status) | ||||
| } | ||||
|  | ||||
| // NewUnexpectedStatusErr creates an ErrUnexpectedStatus from HTTP response | ||||
| func NewUnexpectedStatusErr(resp *http.Response) error { | ||||
| 	var b []byte | ||||
| 	if resp.Body != nil { | ||||
| 		b, _ = ioutil.ReadAll(io.LimitReader(resp.Body, 64000)) // 64KB | ||||
| 	} | ||||
| 	return ErrUnexpectedStatus{Status: resp.Status, StatusCode: resp.StatusCode, Body: b} | ||||
| } | ||||
							
								
								
									
										21
									
								
								vendor/github.com/containerd/containerd/sys/epoll.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								vendor/github.com/containerd/containerd/sys/epoll.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -20,17 +20,14 @@ package sys | ||||
|  | ||||
| import "golang.org/x/sys/unix" | ||||
|  | ||||
| // EpollCreate1 directly calls unix.EpollCreate1 | ||||
| func EpollCreate1(flag int) (int, error) { | ||||
| 	return unix.EpollCreate1(flag) | ||||
| } | ||||
| // EpollCreate1 is an alias for unix.EpollCreate1 | ||||
| // Deprecated: use golang.org/x/sys/unix.EpollCreate1 | ||||
| var EpollCreate1 = unix.EpollCreate1 | ||||
|  | ||||
| // EpollCtl directly calls unix.EpollCtl | ||||
| func EpollCtl(epfd int, op int, fd int, event *unix.EpollEvent) error { | ||||
| 	return unix.EpollCtl(epfd, op, fd, event) | ||||
| } | ||||
| // EpollCtl is an alias for unix.EpollCtl | ||||
| // Deprecated: use golang.org/x/sys/unix.EpollCtl | ||||
| var EpollCtl = unix.EpollCtl | ||||
|  | ||||
| // EpollWait directly calls unix.EpollWait | ||||
| func EpollWait(epfd int, events []unix.EpollEvent, msec int) (int, error) { | ||||
| 	return unix.EpollWait(epfd, events, msec) | ||||
| } | ||||
| // EpollWait is an alias for unix.EpollWait | ||||
| // Deprecated: use golang.org/x/sys/unix.EpollWait | ||||
| var EpollWait = unix.EpollWait | ||||
|   | ||||
							
								
								
									
										35
									
								
								vendor/github.com/containerd/containerd/sys/filesys.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								vendor/github.com/containerd/containerd/sys/filesys.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| /* | ||||
|    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 sys | ||||
|  | ||||
| import "os" | ||||
|  | ||||
| // IsFifo checks if a file is a (named pipe) fifo | ||||
| // if the file does not exist then it returns false | ||||
| func IsFifo(path string) (bool, error) { | ||||
| 	stat, err := os.Stat(path) | ||||
| 	if err != nil { | ||||
| 		if os.IsNotExist(err) { | ||||
| 			return false, nil | ||||
| 		} | ||||
| 		return false, err | ||||
| 	} | ||||
| 	if stat.Mode()&os.ModeNamedPipe == os.ModeNamedPipe { | ||||
| 		return true, nil | ||||
| 	} | ||||
| 	return false, nil | ||||
| } | ||||
							
								
								
									
										89
									
								
								vendor/github.com/containerd/containerd/sys/filesys_windows.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										89
									
								
								vendor/github.com/containerd/containerd/sys/filesys_windows.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -26,8 +26,8 @@ import ( | ||||
| 	"syscall" | ||||
| 	"unsafe" | ||||
|  | ||||
| 	winio "github.com/Microsoft/go-winio" | ||||
| 	"github.com/Microsoft/hcsshim" | ||||
| 	"golang.org/x/sys/windows" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| @@ -41,7 +41,8 @@ func MkdirAllWithACL(path string, perm os.FileMode) error { | ||||
| 	return mkdirall(path, true) | ||||
| } | ||||
|  | ||||
| // MkdirAll implementation that is volume path aware for Windows. | ||||
| // MkdirAll implementation that is volume path aware for Windows. It can be used | ||||
| // as a drop-in replacement for os.MkdirAll() | ||||
| func MkdirAll(path string, _ os.FileMode) error { | ||||
| 	return mkdirall(path, false) | ||||
| } | ||||
| @@ -111,26 +112,26 @@ func mkdirall(path string, adminAndLocalSystem bool) error { | ||||
| // mkdirWithACL creates a new directory. If there is an error, it will be of | ||||
| // type *PathError. . | ||||
| // | ||||
| // This is a modified and combined version of os.Mkdir and syscall.Mkdir | ||||
| // This is a modified and combined version of os.Mkdir and windows.Mkdir | ||||
| // in golang to cater for creating a directory am ACL permitting full | ||||
| // access, with inheritance, to any subfolder/file for Built-in Administrators | ||||
| // and Local System. | ||||
| func mkdirWithACL(name string) error { | ||||
| 	sa := syscall.SecurityAttributes{Length: 0} | ||||
| 	sd, err := winio.SddlToSecurityDescriptor(SddlAdministratorsLocalSystem) | ||||
| 	sa := windows.SecurityAttributes{Length: 0} | ||||
| 	sd, err := windows.SecurityDescriptorFromString(SddlAdministratorsLocalSystem) | ||||
| 	if err != nil { | ||||
| 		return &os.PathError{Op: "mkdir", Path: name, Err: err} | ||||
| 	} | ||||
| 	sa.Length = uint32(unsafe.Sizeof(sa)) | ||||
| 	sa.InheritHandle = 1 | ||||
| 	sa.SecurityDescriptor = uintptr(unsafe.Pointer(&sd[0])) | ||||
| 	sa.SecurityDescriptor = sd | ||||
|  | ||||
| 	namep, err := syscall.UTF16PtrFromString(name) | ||||
| 	namep, err := windows.UTF16PtrFromString(name) | ||||
| 	if err != nil { | ||||
| 		return &os.PathError{Op: "mkdir", Path: name, Err: err} | ||||
| 	} | ||||
|  | ||||
| 	e := syscall.CreateDirectory(namep, &sa) | ||||
| 	e := windows.CreateDirectory(namep, &sa) | ||||
| 	if e != nil { | ||||
| 		return &os.PathError{Op: "mkdir", Path: name, Err: e} | ||||
| 	} | ||||
| @@ -153,7 +154,7 @@ func IsAbs(path string) bool { | ||||
| 	return true | ||||
| } | ||||
|  | ||||
| // The origin of the functions below here are the golang OS and syscall packages, | ||||
| // The origin of the functions below here are the golang OS and windows packages, | ||||
| // slightly modified to only cope with files, not directories due to the | ||||
| // specific use case. | ||||
| // | ||||
| @@ -185,74 +186,74 @@ func OpenFileSequential(name string, flag int, _ os.FileMode) (*os.File, error) | ||||
| 	if name == "" { | ||||
| 		return nil, &os.PathError{Op: "open", Path: name, Err: syscall.ENOENT} | ||||
| 	} | ||||
| 	r, errf := syscallOpenFileSequential(name, flag, 0) | ||||
| 	r, errf := windowsOpenFileSequential(name, flag, 0) | ||||
| 	if errf == nil { | ||||
| 		return r, nil | ||||
| 	} | ||||
| 	return nil, &os.PathError{Op: "open", Path: name, Err: errf} | ||||
| } | ||||
|  | ||||
| func syscallOpenFileSequential(name string, flag int, _ os.FileMode) (file *os.File, err error) { | ||||
| 	r, e := syscallOpenSequential(name, flag|syscall.O_CLOEXEC, 0) | ||||
| func windowsOpenFileSequential(name string, flag int, _ os.FileMode) (file *os.File, err error) { | ||||
| 	r, e := windowsOpenSequential(name, flag|windows.O_CLOEXEC, 0) | ||||
| 	if e != nil { | ||||
| 		return nil, e | ||||
| 	} | ||||
| 	return os.NewFile(uintptr(r), name), nil | ||||
| } | ||||
|  | ||||
| func makeInheritSa() *syscall.SecurityAttributes { | ||||
| 	var sa syscall.SecurityAttributes | ||||
| func makeInheritSa() *windows.SecurityAttributes { | ||||
| 	var sa windows.SecurityAttributes | ||||
| 	sa.Length = uint32(unsafe.Sizeof(sa)) | ||||
| 	sa.InheritHandle = 1 | ||||
| 	return &sa | ||||
| } | ||||
|  | ||||
| func syscallOpenSequential(path string, mode int, _ uint32) (fd syscall.Handle, err error) { | ||||
| func windowsOpenSequential(path string, mode int, _ uint32) (fd windows.Handle, err error) { | ||||
| 	if len(path) == 0 { | ||||
| 		return syscall.InvalidHandle, syscall.ERROR_FILE_NOT_FOUND | ||||
| 		return windows.InvalidHandle, windows.ERROR_FILE_NOT_FOUND | ||||
| 	} | ||||
| 	pathp, err := syscall.UTF16PtrFromString(path) | ||||
| 	pathp, err := windows.UTF16PtrFromString(path) | ||||
| 	if err != nil { | ||||
| 		return syscall.InvalidHandle, err | ||||
| 		return windows.InvalidHandle, err | ||||
| 	} | ||||
| 	var access uint32 | ||||
| 	switch mode & (syscall.O_RDONLY | syscall.O_WRONLY | syscall.O_RDWR) { | ||||
| 	case syscall.O_RDONLY: | ||||
| 		access = syscall.GENERIC_READ | ||||
| 	case syscall.O_WRONLY: | ||||
| 		access = syscall.GENERIC_WRITE | ||||
| 	case syscall.O_RDWR: | ||||
| 		access = syscall.GENERIC_READ | syscall.GENERIC_WRITE | ||||
| 	switch mode & (windows.O_RDONLY | windows.O_WRONLY | windows.O_RDWR) { | ||||
| 	case windows.O_RDONLY: | ||||
| 		access = windows.GENERIC_READ | ||||
| 	case windows.O_WRONLY: | ||||
| 		access = windows.GENERIC_WRITE | ||||
| 	case windows.O_RDWR: | ||||
| 		access = windows.GENERIC_READ | windows.GENERIC_WRITE | ||||
| 	} | ||||
| 	if mode&syscall.O_CREAT != 0 { | ||||
| 		access |= syscall.GENERIC_WRITE | ||||
| 	if mode&windows.O_CREAT != 0 { | ||||
| 		access |= windows.GENERIC_WRITE | ||||
| 	} | ||||
| 	if mode&syscall.O_APPEND != 0 { | ||||
| 		access &^= syscall.GENERIC_WRITE | ||||
| 		access |= syscall.FILE_APPEND_DATA | ||||
| 	if mode&windows.O_APPEND != 0 { | ||||
| 		access &^= windows.GENERIC_WRITE | ||||
| 		access |= windows.FILE_APPEND_DATA | ||||
| 	} | ||||
| 	sharemode := uint32(syscall.FILE_SHARE_READ | syscall.FILE_SHARE_WRITE) | ||||
| 	var sa *syscall.SecurityAttributes | ||||
| 	if mode&syscall.O_CLOEXEC == 0 { | ||||
| 	sharemode := uint32(windows.FILE_SHARE_READ | windows.FILE_SHARE_WRITE) | ||||
| 	var sa *windows.SecurityAttributes | ||||
| 	if mode&windows.O_CLOEXEC == 0 { | ||||
| 		sa = makeInheritSa() | ||||
| 	} | ||||
| 	var createmode uint32 | ||||
| 	switch { | ||||
| 	case mode&(syscall.O_CREAT|syscall.O_EXCL) == (syscall.O_CREAT | syscall.O_EXCL): | ||||
| 		createmode = syscall.CREATE_NEW | ||||
| 	case mode&(syscall.O_CREAT|syscall.O_TRUNC) == (syscall.O_CREAT | syscall.O_TRUNC): | ||||
| 		createmode = syscall.CREATE_ALWAYS | ||||
| 	case mode&syscall.O_CREAT == syscall.O_CREAT: | ||||
| 		createmode = syscall.OPEN_ALWAYS | ||||
| 	case mode&syscall.O_TRUNC == syscall.O_TRUNC: | ||||
| 		createmode = syscall.TRUNCATE_EXISTING | ||||
| 	case mode&(windows.O_CREAT|windows.O_EXCL) == (windows.O_CREAT | windows.O_EXCL): | ||||
| 		createmode = windows.CREATE_NEW | ||||
| 	case mode&(windows.O_CREAT|windows.O_TRUNC) == (windows.O_CREAT | windows.O_TRUNC): | ||||
| 		createmode = windows.CREATE_ALWAYS | ||||
| 	case mode&windows.O_CREAT == windows.O_CREAT: | ||||
| 		createmode = windows.OPEN_ALWAYS | ||||
| 	case mode&windows.O_TRUNC == windows.O_TRUNC: | ||||
| 		createmode = windows.TRUNCATE_EXISTING | ||||
| 	default: | ||||
| 		createmode = syscall.OPEN_EXISTING | ||||
| 		createmode = windows.OPEN_EXISTING | ||||
| 	} | ||||
| 	// Use FILE_FLAG_SEQUENTIAL_SCAN rather than FILE_ATTRIBUTE_NORMAL as implemented in golang. | ||||
| 	//https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx | ||||
| 	// https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx | ||||
| 	const fileFlagSequentialScan = 0x08000000 // FILE_FLAG_SEQUENTIAL_SCAN | ||||
| 	h, e := syscall.CreateFile(pathp, access, sharemode, sa, createmode, fileFlagSequentialScan, 0) | ||||
| 	h, e := windows.CreateFile(pathp, access, sharemode, sa, createmode, fileFlagSequentialScan, 0) | ||||
| 	return h, e | ||||
| } | ||||
|  | ||||
|   | ||||
							
								
								
									
										52
									
								
								vendor/github.com/containerd/containerd/sys/mount_linux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										52
									
								
								vendor/github.com/containerd/containerd/sys/mount_linux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -21,6 +21,7 @@ import ( | ||||
| 	"syscall" | ||||
| 	"unsafe" | ||||
|  | ||||
| 	"github.com/containerd/containerd/log" | ||||
| 	"github.com/pkg/errors" | ||||
| 	"golang.org/x/sys/unix" | ||||
| ) | ||||
| @@ -30,9 +31,8 @@ func FMountat(dirfd uintptr, source, target, fstype string, flags uintptr, data | ||||
| 	var ( | ||||
| 		sourceP, targetP, fstypeP, dataP *byte | ||||
| 		pid                              uintptr | ||||
| 		ws                               unix.WaitStatus | ||||
| 		err                              error | ||||
| 		errno                            syscall.Errno | ||||
| 		errno, status                    syscall.Errno | ||||
| 	) | ||||
|  | ||||
| 	sourceP, err = syscall.BytePtrFromString(source) | ||||
| @@ -60,37 +60,62 @@ func FMountat(dirfd uintptr, source, target, fstype string, flags uintptr, data | ||||
| 	runtime.LockOSThread() | ||||
| 	defer runtime.UnlockOSThread() | ||||
|  | ||||
| 	var pipefds [2]int | ||||
| 	if err := syscall.Pipe2(pipefds[:], syscall.O_CLOEXEC); err != nil { | ||||
| 		return errors.Wrap(err, "failed to open pipe") | ||||
| 	} | ||||
|  | ||||
| 	defer func() { | ||||
| 		// close both ends of the pipe in a deferred function, since open file | ||||
| 		// descriptor table is shared with child | ||||
| 		syscall.Close(pipefds[0]) | ||||
| 		syscall.Close(pipefds[1]) | ||||
| 	}() | ||||
|  | ||||
| 	pid, errno = forkAndMountat(dirfd, | ||||
| 		uintptr(unsafe.Pointer(sourceP)), | ||||
| 		uintptr(unsafe.Pointer(targetP)), | ||||
| 		uintptr(unsafe.Pointer(fstypeP)), | ||||
| 		flags, | ||||
| 		uintptr(unsafe.Pointer(dataP))) | ||||
| 		uintptr(unsafe.Pointer(dataP)), | ||||
| 		pipefds[1], | ||||
| 	) | ||||
|  | ||||
| 	if errno != 0 { | ||||
| 		return errors.Wrap(errno, "failed to fork thread") | ||||
| 	} | ||||
|  | ||||
| 	_, err = unix.Wait4(int(pid), &ws, 0, nil) | ||||
| 	for err == syscall.EINTR { | ||||
| 		_, err = unix.Wait4(int(pid), &ws, 0, nil) | ||||
| 	} | ||||
| 	defer func() { | ||||
| 		_, err := unix.Wait4(int(pid), nil, 0, nil) | ||||
| 		for err == syscall.EINTR { | ||||
| 			_, err = unix.Wait4(int(pid), nil, 0, nil) | ||||
| 		} | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return errors.Wrapf(err, "failed to find pid=%d process", pid) | ||||
| 	} | ||||
| 		if err != nil { | ||||
| 			log.L.WithError(err).Debugf("failed to find pid=%d process", pid) | ||||
| 		} | ||||
| 	}() | ||||
|  | ||||
| 	errno = syscall.Errno(ws.ExitStatus()) | ||||
| 	_, _, errno = syscall.RawSyscall(syscall.SYS_READ, | ||||
| 		uintptr(pipefds[0]), | ||||
| 		uintptr(unsafe.Pointer(&status)), | ||||
| 		unsafe.Sizeof(status)) | ||||
| 	if errno != 0 { | ||||
| 		return errors.Wrap(errno, "failed to mount") | ||||
| 		return errors.Wrap(errno, "failed to read pipe") | ||||
| 	} | ||||
|  | ||||
| 	if status != 0 { | ||||
| 		return errors.Wrap(status, "failed to mount") | ||||
| 	} | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // forkAndMountat will fork thread, change working dir and mount. | ||||
| // | ||||
| // precondition: the runtime OS thread must be locked. | ||||
| func forkAndMountat(dirfd uintptr, source, target, fstype, flags, data uintptr) (pid uintptr, errno syscall.Errno) { | ||||
| func forkAndMountat(dirfd uintptr, source, target, fstype, flags, data uintptr, pipefd int) (pid uintptr, errno syscall.Errno) { | ||||
|  | ||||
| 	// block signal during clone | ||||
| 	beforeFork() | ||||
|  | ||||
| @@ -114,6 +139,7 @@ func forkAndMountat(dirfd uintptr, source, target, fstype, flags, data uintptr) | ||||
| 	_, _, errno = syscall.RawSyscall6(syscall.SYS_MOUNT, source, target, fstype, flags, data, 0) | ||||
|  | ||||
| childerr: | ||||
| 	_, _, errno = syscall.RawSyscall(syscall.SYS_WRITE, uintptr(pipefd), uintptr(unsafe.Pointer(&errno)), unsafe.Sizeof(errno)) | ||||
| 	syscall.RawSyscall(syscall.SYS_EXIT, uintptr(errno), 0, 0) | ||||
| 	panic("unreachable") | ||||
| } | ||||
|   | ||||
							
								
								
									
										4
									
								
								vendor/github.com/containerd/containerd/sys/oom_unix.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								vendor/github.com/containerd/containerd/sys/oom_unix.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -24,8 +24,6 @@ import ( | ||||
| 	"os" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/opencontainers/runc/libcontainer/system" | ||||
| ) | ||||
|  | ||||
| // OOMScoreMaxKillable is the maximum score keeping the process killable by the oom killer | ||||
| @@ -40,7 +38,7 @@ func SetOOMScore(pid, score int) error { | ||||
| 	} | ||||
| 	defer f.Close() | ||||
| 	if _, err = f.WriteString(strconv.Itoa(score)); err != nil { | ||||
| 		if os.IsPermission(err) && (system.RunningInUserNS() || RunningUnprivileged()) { | ||||
| 		if os.IsPermission(err) && (RunningInUserNS() || RunningUnprivileged()) { | ||||
| 			return nil | ||||
| 		} | ||||
| 		return err | ||||
|   | ||||
							
								
								
									
										80
									
								
								vendor/github.com/containerd/containerd/sys/proc.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										80
									
								
								vendor/github.com/containerd/containerd/sys/proc.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,80 +0,0 @@ | ||||
| // +build linux | ||||
|  | ||||
| /* | ||||
|    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 sys | ||||
|  | ||||
| import ( | ||||
| 	"bufio" | ||||
| 	"fmt" | ||||
| 	"os" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/opencontainers/runc/libcontainer/system" | ||||
| ) | ||||
|  | ||||
| const nanoSecondsPerSecond = 1e9 | ||||
|  | ||||
| var clockTicksPerSecond = uint64(system.GetClockTicks()) | ||||
|  | ||||
| // GetSystemCPUUsage returns the host system's cpu usage in | ||||
| // nanoseconds. An error is returned if the format of the underlying | ||||
| // file does not match. | ||||
| // | ||||
| // Uses /proc/stat defined by POSIX. Looks for the cpu | ||||
| // statistics line and then sums up the first seven fields | ||||
| // provided. See `man 5 proc` for details on specific field | ||||
| // information. | ||||
| func GetSystemCPUUsage() (uint64, error) { | ||||
| 	var line string | ||||
| 	f, err := os.Open("/proc/stat") | ||||
| 	if err != nil { | ||||
| 		return 0, err | ||||
| 	} | ||||
| 	bufReader := bufio.NewReaderSize(nil, 128) | ||||
| 	defer func() { | ||||
| 		bufReader.Reset(nil) | ||||
| 		f.Close() | ||||
| 	}() | ||||
| 	bufReader.Reset(f) | ||||
| 	err = nil | ||||
| 	for err == nil { | ||||
| 		line, err = bufReader.ReadString('\n') | ||||
| 		if err != nil { | ||||
| 			break | ||||
| 		} | ||||
| 		parts := strings.Fields(line) | ||||
| 		switch parts[0] { | ||||
| 		case "cpu": | ||||
| 			if len(parts) < 8 { | ||||
| 				return 0, fmt.Errorf("bad format of cpu stats") | ||||
| 			} | ||||
| 			var totalClockTicks uint64 | ||||
| 			for _, i := range parts[1:8] { | ||||
| 				v, err := strconv.ParseUint(i, 10, 64) | ||||
| 				if err != nil { | ||||
| 					return 0, fmt.Errorf("error parsing cpu stats") | ||||
| 				} | ||||
| 				totalClockTicks += v | ||||
| 			} | ||||
| 			return (totalClockTicks * nanoSecondsPerSecond) / | ||||
| 				clockTicksPerSecond, nil | ||||
| 		} | ||||
| 	} | ||||
| 	return 0, fmt.Errorf("bad stats format") | ||||
| } | ||||
							
								
								
									
										69
									
								
								vendor/github.com/containerd/containerd/sys/reaper.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										69
									
								
								vendor/github.com/containerd/containerd/sys/reaper.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,69 +0,0 @@ | ||||
| // +build !windows | ||||
|  | ||||
| /* | ||||
|    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 sys | ||||
|  | ||||
| import ( | ||||
| 	"golang.org/x/sys/unix" | ||||
| ) | ||||
|  | ||||
| // Exit is the wait4 information from an exited process | ||||
| type Exit struct { | ||||
| 	Pid    int | ||||
| 	Status int | ||||
| } | ||||
|  | ||||
| // Reap reaps all child processes for the calling process and returns their | ||||
| // exit information | ||||
| func Reap(wait bool) (exits []Exit, err error) { | ||||
| 	var ( | ||||
| 		ws  unix.WaitStatus | ||||
| 		rus unix.Rusage | ||||
| 	) | ||||
| 	flag := unix.WNOHANG | ||||
| 	if wait { | ||||
| 		flag = 0 | ||||
| 	} | ||||
| 	for { | ||||
| 		pid, err := unix.Wait4(-1, &ws, flag, &rus) | ||||
| 		if err != nil { | ||||
| 			if err == unix.ECHILD { | ||||
| 				return exits, nil | ||||
| 			} | ||||
| 			return exits, err | ||||
| 		} | ||||
| 		if pid <= 0 { | ||||
| 			return exits, nil | ||||
| 		} | ||||
| 		exits = append(exits, Exit{ | ||||
| 			Pid:    pid, | ||||
| 			Status: exitStatus(ws), | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| const exitSignalOffset = 128 | ||||
|  | ||||
| // exitStatus returns the correct exit status for a process based on if it | ||||
| // was signaled or exited cleanly | ||||
| func exitStatus(status unix.WaitStatus) int { | ||||
| 	if status.Signaled() { | ||||
| 		return exitSignalOffset + int(status.Signal()) | ||||
| 	} | ||||
| 	return status.ExitStatus() | ||||
| } | ||||
							
								
								
									
										52
									
								
								vendor/github.com/containerd/containerd/sys/reaper_linux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										52
									
								
								vendor/github.com/containerd/containerd/sys/reaper_linux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,52 +0,0 @@ | ||||
| /* | ||||
|    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 sys | ||||
|  | ||||
| import ( | ||||
| 	"unsafe" | ||||
|  | ||||
| 	"golang.org/x/sys/unix" | ||||
| ) | ||||
|  | ||||
| // If arg2 is nonzero, set the "child subreaper" attribute of the | ||||
| // calling process; if arg2 is zero, unset the attribute.  When a | ||||
| // process is marked as a child subreaper, all of the children | ||||
| // that it creates, and their descendants, will be marked as | ||||
| // having a subreaper.  In effect, a subreaper fulfills the role | ||||
| // of init(1) for its descendant processes.  Upon termination of | ||||
| // a process that is orphaned (i.e., its immediate parent has | ||||
| // already terminated) and marked as having a subreaper, the | ||||
| // nearest still living ancestor subreaper will receive a SIGCHLD | ||||
| // signal and be able to wait(2) on the process to discover its | ||||
| // termination status. | ||||
| const setChildSubreaper = 36 | ||||
|  | ||||
| // SetSubreaper sets the value i as the subreaper setting for the calling process | ||||
| func SetSubreaper(i int) error { | ||||
| 	return unix.Prctl(setChildSubreaper, uintptr(i), 0, 0, 0) | ||||
| } | ||||
|  | ||||
| // GetSubreaper returns the subreaper setting for the calling process | ||||
| func GetSubreaper() (int, error) { | ||||
| 	var i uintptr | ||||
|  | ||||
| 	if err := unix.Prctl(unix.PR_GET_CHILD_SUBREAPER, uintptr(unsafe.Pointer(&i)), 0, 0, 0); err != nil { | ||||
| 		return -1, err | ||||
| 	} | ||||
|  | ||||
| 	return int(i), nil | ||||
| } | ||||
							
								
								
									
										62
									
								
								vendor/github.com/containerd/containerd/sys/userns_linux.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										62
									
								
								vendor/github.com/containerd/containerd/sys/userns_linux.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,62 @@ | ||||
| /* | ||||
|    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 sys | ||||
|  | ||||
| import ( | ||||
| 	"bufio" | ||||
| 	"fmt" | ||||
| 	"os" | ||||
| 	"sync" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	inUserNS bool | ||||
| 	nsOnce   sync.Once | ||||
| ) | ||||
|  | ||||
| // RunningInUserNS detects whether we are currently running in a user namespace. | ||||
| // Originally copied from github.com/lxc/lxd/shared/util.go | ||||
| func RunningInUserNS() bool { | ||||
| 	nsOnce.Do(func() { | ||||
| 		file, err := os.Open("/proc/self/uid_map") | ||||
| 		if err != nil { | ||||
| 			// This kernel-provided file only exists if user namespaces are supported | ||||
| 			return | ||||
| 		} | ||||
| 		defer file.Close() | ||||
|  | ||||
| 		buf := bufio.NewReader(file) | ||||
| 		l, _, err := buf.ReadLine() | ||||
| 		if err != nil { | ||||
| 			return | ||||
| 		} | ||||
|  | ||||
| 		line := string(l) | ||||
| 		var a, b, c int64 | ||||
| 		fmt.Sscanf(line, "%d %d %d", &a, &b, &c) | ||||
|  | ||||
| 		/* | ||||
| 		 * We assume we are in the initial user namespace if we have a full | ||||
| 		 * range - 4294967295 uids starting at uid 0. | ||||
| 		 */ | ||||
| 		if a == 0 && b == 0 && c == 4294967295 { | ||||
| 			return | ||||
| 		} | ||||
| 		inUserNS = true | ||||
| 	}) | ||||
| 	return inUserNS | ||||
| } | ||||
| @@ -1,4 +1,4 @@ | ||||
| // +build !windows | ||||
| // +build !linux | ||||
| 
 | ||||
| /* | ||||
|    Copyright The containerd Authors. | ||||
| @@ -16,11 +16,10 @@ | ||||
|    limitations under the License. | ||||
| */ | ||||
| 
 | ||||
| package syscallx | ||||
| package sys | ||||
| 
 | ||||
| import "syscall" | ||||
| 
 | ||||
| // Readlink returns the destination of the named symbolic link. | ||||
| func Readlink(path string, buf []byte) (n int, err error) { | ||||
| 	return syscall.Readlink(path, buf) | ||||
| // RunningInUserNS is a stub for non-Linux systems | ||||
| // Always returns false | ||||
| func RunningInUserNS() bool { | ||||
| 	return false | ||||
| } | ||||
							
								
								
									
										2
									
								
								vendor/github.com/containerd/containerd/version/version.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/containerd/containerd/version/version.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -23,7 +23,7 @@ var ( | ||||
| 	Package = "github.com/containerd/containerd" | ||||
|  | ||||
| 	// Version holds the complete version number. Filled in at linking time. | ||||
| 	Version = "1.3.0+unknown" | ||||
| 	Version = "1.4.0+unknown" | ||||
|  | ||||
| 	// Revision is filled with the VCS (e.g. git) revision being used to build | ||||
| 	// the program at linking time. | ||||
|   | ||||
							
								
								
									
										20
									
								
								vendor/github.com/containerd/continuity/AUTHORS
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										20
									
								
								vendor/github.com/containerd/continuity/AUTHORS
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,16 +1,36 @@ | ||||
| Aaron Lehmann <aaron.lehmann@docker.com> | ||||
| Akash Gupta <akagup@microsoft.com> | ||||
| Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp> | ||||
| Akihiro Suda <suda.akihiro@lab.ntt.co.jp> | ||||
| Akihiro Suda <suda.kyoto@gmail.com> | ||||
| Andrew Pennebaker <apennebaker@datapipe.com> | ||||
| Brandon Philips <brandon.philips@coreos.com> | ||||
| Brian Goff <cpuguy83@gmail.com> | ||||
| Christopher Jones <tophj@linux.vnet.ibm.com> | ||||
| Daniel, Dao Quang Minh <dqminh89@gmail.com> | ||||
| Darren Stahl <darst@microsoft.com> | ||||
| Derek McGowan <derek@mcg.dev> | ||||
| Derek McGowan <derek@mcgstyle.net> | ||||
| Edward Pilatowicz <edward.pilatowicz@oracle.com> | ||||
| Ian Campbell <ijc@docker.com> | ||||
| Ivan Markin <sw@nogoegst.net> | ||||
| Justin Cormack <justin.cormack@docker.com> | ||||
| Justin Cummins <sul3n3t@gmail.com> | ||||
| Kasper Fabæch Brandt <poizan@poizan.dk> | ||||
| Kir Kolyshkin <kolyshkin@gmail.com> | ||||
| Michael Crosby <crosbymichael@gmail.com> | ||||
| Michael Wan <zirenwan@gmail.com> | ||||
| Niels de Vos <ndevos@redhat.com> | ||||
| Phil Estes <estesp@gmail.com> | ||||
| Phil Estes <estesp@linux.vnet.ibm.com> | ||||
| Sam Whited <sam@samwhited.com> | ||||
| Shengjing Zhu <zhsj@debian.org> | ||||
| Stephen J Day <stephen.day@docker.com> | ||||
| Tibor Vass <tibor@docker.com> | ||||
| Tobias Klauser <tklauser@distanz.ch> | ||||
| Tom Faulhaber <tffaulha@amazon.com> | ||||
| Tonis Tiigi <tonistiigi@gmail.com> | ||||
| Trevor Porter <trkporter@ucdavis.edu> | ||||
| Wei Fu <fuweid89@gmail.com> | ||||
| Wilbert van de Ridder <wilbert.ridder@gmail.com> | ||||
| Xiaodong Ye <xiaodongy@vmware.com> | ||||
|   | ||||
							
								
								
									
										112
									
								
								vendor/github.com/containerd/continuity/syscallx/syscall_windows.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										112
									
								
								vendor/github.com/containerd/continuity/syscallx/syscall_windows.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,112 +0,0 @@ | ||||
| /* | ||||
|    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 syscallx | ||||
|  | ||||
| import ( | ||||
| 	"syscall" | ||||
| 	"unsafe" | ||||
| ) | ||||
|  | ||||
| type reparseDataBuffer struct { | ||||
| 	ReparseTag        uint32 | ||||
| 	ReparseDataLength uint16 | ||||
| 	Reserved          uint16 | ||||
|  | ||||
| 	// GenericReparseBuffer | ||||
| 	reparseBuffer byte | ||||
| } | ||||
|  | ||||
| type mountPointReparseBuffer struct { | ||||
| 	SubstituteNameOffset uint16 | ||||
| 	SubstituteNameLength uint16 | ||||
| 	PrintNameOffset      uint16 | ||||
| 	PrintNameLength      uint16 | ||||
| 	PathBuffer           [1]uint16 | ||||
| } | ||||
|  | ||||
| type symbolicLinkReparseBuffer struct { | ||||
| 	SubstituteNameOffset uint16 | ||||
| 	SubstituteNameLength uint16 | ||||
| 	PrintNameOffset      uint16 | ||||
| 	PrintNameLength      uint16 | ||||
| 	Flags                uint32 | ||||
| 	PathBuffer           [1]uint16 | ||||
| } | ||||
|  | ||||
| const ( | ||||
| 	_IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003 | ||||
| 	_SYMLINK_FLAG_RELATIVE      = 1 | ||||
| ) | ||||
|  | ||||
| // Readlink returns the destination of the named symbolic link. | ||||
| func Readlink(path string, buf []byte) (n int, err error) { | ||||
| 	fd, err := syscall.CreateFile(syscall.StringToUTF16Ptr(path), syscall.GENERIC_READ, 0, nil, syscall.OPEN_EXISTING, | ||||
| 		syscall.FILE_FLAG_OPEN_REPARSE_POINT|syscall.FILE_FLAG_BACKUP_SEMANTICS, 0) | ||||
| 	if err != nil { | ||||
| 		return -1, err | ||||
| 	} | ||||
| 	defer syscall.CloseHandle(fd) | ||||
|  | ||||
| 	rdbbuf := make([]byte, syscall.MAXIMUM_REPARSE_DATA_BUFFER_SIZE) | ||||
| 	var bytesReturned uint32 | ||||
| 	err = syscall.DeviceIoControl(fd, syscall.FSCTL_GET_REPARSE_POINT, nil, 0, &rdbbuf[0], uint32(len(rdbbuf)), &bytesReturned, nil) | ||||
| 	if err != nil { | ||||
| 		return -1, err | ||||
| 	} | ||||
|  | ||||
| 	rdb := (*reparseDataBuffer)(unsafe.Pointer(&rdbbuf[0])) | ||||
| 	var s string | ||||
| 	switch rdb.ReparseTag { | ||||
| 	case syscall.IO_REPARSE_TAG_SYMLINK: | ||||
| 		data := (*symbolicLinkReparseBuffer)(unsafe.Pointer(&rdb.reparseBuffer)) | ||||
| 		p := (*[0xffff]uint16)(unsafe.Pointer(&data.PathBuffer[0])) | ||||
| 		s = syscall.UTF16ToString(p[data.SubstituteNameOffset/2 : (data.SubstituteNameOffset+data.SubstituteNameLength)/2]) | ||||
| 		if data.Flags&_SYMLINK_FLAG_RELATIVE == 0 { | ||||
| 			if len(s) >= 4 && s[:4] == `\??\` { | ||||
| 				s = s[4:] | ||||
| 				switch { | ||||
| 				case len(s) >= 2 && s[1] == ':': // \??\C:\foo\bar | ||||
| 					// do nothing | ||||
| 				case len(s) >= 4 && s[:4] == `UNC\`: // \??\UNC\foo\bar | ||||
| 					s = `\\` + s[4:] | ||||
| 				default: | ||||
| 					// unexpected; do nothing | ||||
| 				} | ||||
| 			} else { | ||||
| 				// unexpected; do nothing | ||||
| 			} | ||||
| 		} | ||||
| 	case _IO_REPARSE_TAG_MOUNT_POINT: | ||||
| 		data := (*mountPointReparseBuffer)(unsafe.Pointer(&rdb.reparseBuffer)) | ||||
| 		p := (*[0xffff]uint16)(unsafe.Pointer(&data.PathBuffer[0])) | ||||
| 		s = syscall.UTF16ToString(p[data.SubstituteNameOffset/2 : (data.SubstituteNameOffset+data.SubstituteNameLength)/2]) | ||||
| 		if len(s) >= 4 && s[:4] == `\??\` { // \??\C:\foo\bar | ||||
| 			if len(s) < 48 || s[:11] != `\??\Volume{` { | ||||
| 				s = s[4:] | ||||
| 			} | ||||
| 		} else { | ||||
| 			// unexpected; do nothing | ||||
| 		} | ||||
| 	default: | ||||
| 		// the path is not a symlink or junction but another type of reparse | ||||
| 		// point | ||||
| 		return -1, syscall.ENOENT | ||||
| 	} | ||||
| 	n = copy(buf, []byte(s)) | ||||
|  | ||||
| 	return n, nil | ||||
| } | ||||
							
								
								
									
										128
									
								
								vendor/github.com/containerd/continuity/sysx/file_posix.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										128
									
								
								vendor/github.com/containerd/continuity/sysx/file_posix.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,128 +0,0 @@ | ||||
| /* | ||||
|    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 sysx | ||||
|  | ||||
| import ( | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
|  | ||||
| 	"github.com/containerd/continuity/syscallx" | ||||
| ) | ||||
|  | ||||
| // Readlink returns the destination of the named symbolic link. | ||||
| // If there is an error, it will be of type *PathError. | ||||
| func Readlink(name string) (string, error) { | ||||
| 	for len := 128; ; len *= 2 { | ||||
| 		b := make([]byte, len) | ||||
| 		n, e := fixCount(syscallx.Readlink(fixLongPath(name), b)) | ||||
| 		if e != nil { | ||||
| 			return "", &os.PathError{Op: "readlink", Path: name, Err: e} | ||||
| 		} | ||||
| 		if n < len { | ||||
| 			return string(b[0:n]), nil | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
| // Many functions in package syscall return a count of -1 instead of 0. | ||||
| // Using fixCount(call()) instead of call() corrects the count. | ||||
| func fixCount(n int, err error) (int, error) { | ||||
| 	if n < 0 { | ||||
| 		n = 0 | ||||
| 	} | ||||
| 	return n, err | ||||
| } | ||||
|  | ||||
| // fixLongPath returns the extended-length (\\?\-prefixed) form of | ||||
| // path when needed, in order to avoid the default 260 character file | ||||
| // path limit imposed by Windows. If path is not easily converted to | ||||
| // the extended-length form (for example, if path is a relative path | ||||
| // or contains .. elements), or is short enough, fixLongPath returns | ||||
| // path unmodified. | ||||
| // | ||||
| // See https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#maxpath | ||||
| func fixLongPath(path string) string { | ||||
| 	// Do nothing (and don't allocate) if the path is "short". | ||||
| 	// Empirically (at least on the Windows Server 2013 builder), | ||||
| 	// the kernel is arbitrarily okay with < 248 bytes. That | ||||
| 	// matches what the docs above say: | ||||
| 	// "When using an API to create a directory, the specified | ||||
| 	// path cannot be so long that you cannot append an 8.3 file | ||||
| 	// name (that is, the directory name cannot exceed MAX_PATH | ||||
| 	// minus 12)." Since MAX_PATH is 260, 260 - 12 = 248. | ||||
| 	// | ||||
| 	// The MSDN docs appear to say that a normal path that is 248 bytes long | ||||
| 	// will work; empirically the path must be less then 248 bytes long. | ||||
| 	if len(path) < 248 { | ||||
| 		// Don't fix. (This is how Go 1.7 and earlier worked, | ||||
| 		// not automatically generating the \\?\ form) | ||||
| 		return path | ||||
| 	} | ||||
|  | ||||
| 	// The extended form begins with \\?\, as in | ||||
| 	// \\?\c:\windows\foo.txt or \\?\UNC\server\share\foo.txt. | ||||
| 	// The extended form disables evaluation of . and .. path | ||||
| 	// elements and disables the interpretation of / as equivalent | ||||
| 	// to \. The conversion here rewrites / to \ and elides | ||||
| 	// . elements as well as trailing or duplicate separators. For | ||||
| 	// simplicity it avoids the conversion entirely for relative | ||||
| 	// paths or paths containing .. elements. For now, | ||||
| 	// \\server\share paths are not converted to | ||||
| 	// \\?\UNC\server\share paths because the rules for doing so | ||||
| 	// are less well-specified. | ||||
| 	if len(path) >= 2 && path[:2] == `\\` { | ||||
| 		// Don't canonicalize UNC paths. | ||||
| 		return path | ||||
| 	} | ||||
| 	if !filepath.IsAbs(path) { | ||||
| 		// Relative path | ||||
| 		return path | ||||
| 	} | ||||
|  | ||||
| 	const prefix = `\\?` | ||||
|  | ||||
| 	pathbuf := make([]byte, len(prefix)+len(path)+len(`\`)) | ||||
| 	copy(pathbuf, prefix) | ||||
| 	n := len(path) | ||||
| 	r, w := 0, len(prefix) | ||||
| 	for r < n { | ||||
| 		switch { | ||||
| 		case os.IsPathSeparator(path[r]): | ||||
| 			// empty block | ||||
| 			r++ | ||||
| 		case path[r] == '.' && (r+1 == n || os.IsPathSeparator(path[r+1])): | ||||
| 			// /./ | ||||
| 			r++ | ||||
| 		case r+1 < n && path[r] == '.' && path[r+1] == '.' && (r+2 == n || os.IsPathSeparator(path[r+2])): | ||||
| 			// /../ is currently unhandled | ||||
| 			return path | ||||
| 		default: | ||||
| 			pathbuf[w] = '\\' | ||||
| 			w++ | ||||
| 			for ; r < n && !os.IsPathSeparator(path[r]); r++ { | ||||
| 				pathbuf[w] = path[r] | ||||
| 				w++ | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	// A drive's root directory needs a trailing \ | ||||
| 	if w == len(`\\?\c:`) { | ||||
| 		pathbuf[w] = '\\' | ||||
| 		w++ | ||||
| 	} | ||||
| 	return string(pathbuf[:w]) | ||||
| } | ||||
							
								
								
									
										72
									
								
								vendor/github.com/containerd/continuity/sysx/xattr.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										72
									
								
								vendor/github.com/containerd/continuity/sysx/xattr.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -20,7 +20,6 @@ package sysx | ||||
|  | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"syscall" | ||||
|  | ||||
| 	"golang.org/x/sys/unix" | ||||
| ) | ||||
| @@ -66,60 +65,53 @@ func LGetxattr(path, attr string) ([]byte, error) { | ||||
| 	return getxattrAll(path, attr, unix.Lgetxattr) | ||||
| } | ||||
|  | ||||
| const defaultXattrBufferSize = 5 | ||||
| const defaultXattrBufferSize = 128 | ||||
|  | ||||
| type listxattrFunc func(path string, dest []byte) (int, error) | ||||
|  | ||||
| func listxattrAll(path string, listFunc listxattrFunc) ([]string, error) { | ||||
| 	var p []byte // nil on first execution | ||||
|  | ||||
| 	for { | ||||
| 		n, err := listFunc(path, p) // first call gets buffer size. | ||||
| 	buf := make([]byte, defaultXattrBufferSize) | ||||
| 	n, err := listFunc(path, buf) | ||||
| 	for err == unix.ERANGE { | ||||
| 		// Buffer too small, use zero-sized buffer to get the actual size | ||||
| 		n, err = listFunc(path, []byte{}) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
|  | ||||
| 		if n > len(p) { | ||||
| 			p = make([]byte, n) | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| 		p = p[:n] | ||||
|  | ||||
| 		ps := bytes.Split(bytes.TrimSuffix(p, []byte{0}), []byte{0}) | ||||
| 		var entries []string | ||||
| 		for _, p := range ps { | ||||
| 			s := string(p) | ||||
| 			if s != "" { | ||||
| 				entries = append(entries, s) | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		return entries, nil | ||||
| 		buf = make([]byte, n) | ||||
| 		n, err = listFunc(path, buf) | ||||
| 	} | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	ps := bytes.Split(bytes.TrimSuffix(buf[:n], []byte{0}), []byte{0}) | ||||
| 	var entries []string | ||||
| 	for _, p := range ps { | ||||
| 		if len(p) > 0 { | ||||
| 			entries = append(entries, string(p)) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	return entries, nil | ||||
| } | ||||
|  | ||||
| type getxattrFunc func(string, string, []byte) (int, error) | ||||
|  | ||||
| func getxattrAll(path, attr string, getFunc getxattrFunc) ([]byte, error) { | ||||
| 	p := make([]byte, defaultXattrBufferSize) | ||||
| 	for { | ||||
| 		n, err := getFunc(path, attr, p) | ||||
| 	buf := make([]byte, defaultXattrBufferSize) | ||||
| 	n, err := getFunc(path, attr, buf) | ||||
| 	for err == unix.ERANGE { | ||||
| 		// Buffer too small, use zero-sized buffer to get the actual size | ||||
| 		n, err = getFunc(path, attr, []byte{}) | ||||
| 		if err != nil { | ||||
| 			if errno, ok := err.(syscall.Errno); ok && errno == syscall.ERANGE { | ||||
| 				p = make([]byte, len(p)*2) // this can't be ideal. | ||||
| 				continue                   // try again! | ||||
| 			} | ||||
|  | ||||
| 			return nil, err | ||||
| 		} | ||||
|  | ||||
| 		// realloc to correct size and repeat | ||||
| 		if n > len(p) { | ||||
| 			p = make([]byte, n) | ||||
| 			continue | ||||
| 		} | ||||
|  | ||||
| 		return p[:n], nil | ||||
| 		buf = make([]byte, n) | ||||
| 		n, err = getFunc(path, attr, buf) | ||||
| 	} | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return buf[:n], nil | ||||
| } | ||||
|   | ||||
							
								
								
									
										12
									
								
								vendor/github.com/containerd/continuity/sysx/xattr_unsupported.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										12
									
								
								vendor/github.com/containerd/continuity/sysx/xattr_unsupported.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -23,7 +23,7 @@ import ( | ||||
| 	"runtime" | ||||
| ) | ||||
|  | ||||
| var unsupported = errors.New("extended attributes unsupported on " + runtime.GOOS) | ||||
| var errUnsupported = errors.New("extended attributes unsupported on " + runtime.GOOS) | ||||
|  | ||||
| // Listxattr calls syscall listxattr and reads all content | ||||
| // and returns a string array | ||||
| @@ -33,17 +33,17 @@ func Listxattr(path string) ([]string, error) { | ||||
|  | ||||
| // Removexattr calls syscall removexattr | ||||
| func Removexattr(path string, attr string) (err error) { | ||||
| 	return unsupported | ||||
| 	return errUnsupported | ||||
| } | ||||
|  | ||||
| // Setxattr calls syscall setxattr | ||||
| func Setxattr(path string, attr string, data []byte, flags int) (err error) { | ||||
| 	return unsupported | ||||
| 	return errUnsupported | ||||
| } | ||||
|  | ||||
| // Getxattr calls syscall getxattr | ||||
| func Getxattr(path, attr string) ([]byte, error) { | ||||
| 	return []byte{}, unsupported | ||||
| 	return []byte{}, errUnsupported | ||||
| } | ||||
|  | ||||
| // LListxattr lists xattrs, not following symlinks | ||||
| @@ -53,12 +53,12 @@ func LListxattr(path string) ([]string, error) { | ||||
|  | ||||
| // LRemovexattr removes an xattr, not following symlinks | ||||
| func LRemovexattr(path string, attr string) (err error) { | ||||
| 	return unsupported | ||||
| 	return errUnsupported | ||||
| } | ||||
|  | ||||
| // LSetxattr sets an xattr, not following symlinks | ||||
| func LSetxattr(path string, attr string, data []byte, flags int) (err error) { | ||||
| 	return unsupported | ||||
| 	return errUnsupported | ||||
| } | ||||
|  | ||||
| // LGetxattr gets an xattr, not following symlinks | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/containerd/typeurl/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/containerd/typeurl/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| *.test | ||||
| coverage.txt | ||||
| @@ -176,7 +176,7 @@ | ||||
| 
 | ||||
|    END OF TERMS AND CONDITIONS | ||||
| 
 | ||||
|    Copyright 2016 Docker, Inc. | ||||
|    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. | ||||
							
								
								
									
										19
									
								
								vendor/github.com/containerd/typeurl/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								vendor/github.com/containerd/typeurl/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| # typeurl | ||||
|  | ||||
| [](https://travis-ci.org/containerd/typeurl) | ||||
|  | ||||
| [](https://codecov.io/gh/containerd/typeurl) | ||||
|  | ||||
| A Go package for managing the registration, marshaling, and unmarshaling of encoded types. | ||||
|  | ||||
| This package helps when types are sent over a GRPC API and marshaled as a [protobuf.Any](https://github.com/gogo/protobuf/blob/master/protobuf/google/protobuf/any.proto). | ||||
|  | ||||
| ## Project details | ||||
|  | ||||
| **typeurl** is a containerd sub-project, licensed under the [Apache 2.0 license](./LICENSE). | ||||
| As a containerd sub-project, you will find the: | ||||
|  * [Project governance](https://github.com/containerd/project/blob/master/GOVERNANCE.md), | ||||
|  * [Maintainers](https://github.com/containerd/project/blob/master/MAINTAINERS), | ||||
|  * and [Contributing guidelines](https://github.com/containerd/project/blob/master/CONTRIBUTING.md) | ||||
|  | ||||
| information in our [`containerd/project`](https://github.com/containerd/project) repository. | ||||
							
								
								
									
										83
									
								
								vendor/github.com/containerd/typeurl/doc.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								vendor/github.com/containerd/typeurl/doc.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,83 @@ | ||||
| /* | ||||
|    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 typeurl | ||||
|  | ||||
| // Package typeurl assists with managing the registration, marshaling, and | ||||
| // unmarshaling of types encoded as protobuf.Any. | ||||
| // | ||||
| // A protobuf.Any is a proto message that can contain any arbitrary data. It | ||||
| // consists of two components, a TypeUrl and a Value, and its proto definition | ||||
| // looks like this: | ||||
| // | ||||
| //   message Any { | ||||
| //     string type_url = 1; | ||||
| //     bytes value = 2; | ||||
| //   } | ||||
| // | ||||
| // The TypeUrl is used to distinguish the contents from other proto.Any | ||||
| // messages. This typeurl library manages these URLs to enable automagic | ||||
| // marshaling and unmarshaling of the contents. | ||||
| // | ||||
| // For example, consider this go struct: | ||||
| // | ||||
| //   type Foo struct { | ||||
| //     Field1 string | ||||
| //     Field2 string | ||||
| //   } | ||||
| // | ||||
| // To use typeurl, types must first be registered. This is typically done in | ||||
| // the init function | ||||
| // | ||||
| //   func init() { | ||||
| //      typeurl.Register(&Foo{}, "Foo") | ||||
| //   } | ||||
| // | ||||
| // This will register the type Foo with the url path "Foo". The arguments to | ||||
| // Register are variadic, and are used to construct a url path. Consider this | ||||
| // example, from the github.com/containerd/containerd/client package: | ||||
| // | ||||
| //   func init() { | ||||
| //     const prefix = "types.containerd.io" | ||||
| //     // register TypeUrls for commonly marshaled external types | ||||
| //     major := strconv.Itoa(specs.VersionMajor) | ||||
| //     typeurl.Register(&specs.Spec{}, prefix, "opencontainers/runtime-spec", major, "Spec") | ||||
| //     // this function has more Register calls, which are elided. | ||||
| //   } | ||||
| // | ||||
| // This registers several types under a more complex url, which ends up mapping | ||||
| // to `types.containerd.io/opencontainers/runtime-spec/1/Spec` (or some other | ||||
| // value for major). | ||||
| // | ||||
| // Once a type is registered, it can be marshaled to a proto.Any message simply | ||||
| // by calling `MarshalAny`, like this: | ||||
| // | ||||
| //   foo := &Foo{Field1: "value1", Field2: "value2"} | ||||
| //   anyFoo, err := typeurl.MarshalAny(foo) | ||||
| // | ||||
| // MarshalAny will resolve the correct URL for the type. If the type in | ||||
| // question implements the proto.Message interface, then it will be marshaled | ||||
| // as a proto message. Otherwise, it will be marshaled as json. This means that | ||||
| // typeurl will work on any arbitrary data, whether or not it has a proto | ||||
| // definition, as long as it can be serialized to json. | ||||
| // | ||||
| // To unmarshal, the process is simply inverse: | ||||
| // | ||||
| //   iface, err := typeurl.UnmarshalAny(anyFoo) | ||||
| //   foo := iface.(*Foo) | ||||
| // | ||||
| // The correct type is automatically chosen from the type registry, and the | ||||
| // returned interface can be cast straight to that type. | ||||
							
								
								
									
										8
									
								
								vendor/github.com/containerd/typeurl/go.mod
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								vendor/github.com/containerd/typeurl/go.mod
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | ||||
| module github.com/containerd/typeurl | ||||
|  | ||||
| go 1.13 | ||||
|  | ||||
| require ( | ||||
| 	github.com/gogo/protobuf v1.3.1 | ||||
| 	github.com/pkg/errors v0.9.1 | ||||
| ) | ||||
							
								
								
									
										7
									
								
								vendor/github.com/containerd/typeurl/go.sum
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								vendor/github.com/containerd/typeurl/go.sum
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= | ||||
| github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= | ||||
| github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= | ||||
| github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= | ||||
| github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= | ||||
| github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||||
| golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||||
							
								
								
									
										195
									
								
								vendor/github.com/containerd/typeurl/types.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										195
									
								
								vendor/github.com/containerd/typeurl/types.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,195 @@ | ||||
| /* | ||||
|    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 typeurl | ||||
|  | ||||
| import ( | ||||
| 	"encoding/json" | ||||
| 	"path" | ||||
| 	"reflect" | ||||
| 	"sync" | ||||
|  | ||||
| 	"github.com/gogo/protobuf/proto" | ||||
| 	"github.com/gogo/protobuf/types" | ||||
| 	"github.com/pkg/errors" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	mu       sync.Mutex | ||||
| 	registry = make(map[reflect.Type]string) | ||||
| ) | ||||
|  | ||||
| var ErrNotFound = errors.New("not found") | ||||
|  | ||||
| // Register a type with a base URL for JSON marshaling. When the MarshalAny and | ||||
| // UnmarshalAny functions are called they will treat the Any type value as JSON. | ||||
| // To use protocol buffers for handling the Any value the proto.Register | ||||
| // function should be used instead of this function. | ||||
| func Register(v interface{}, args ...string) { | ||||
| 	var ( | ||||
| 		t = tryDereference(v) | ||||
| 		p = path.Join(args...) | ||||
| 	) | ||||
| 	mu.Lock() | ||||
| 	defer mu.Unlock() | ||||
| 	if et, ok := registry[t]; ok { | ||||
| 		if et != p { | ||||
| 			panic(errors.Errorf("type registered with alternate path %q != %q", et, p)) | ||||
| 		} | ||||
| 		return | ||||
| 	} | ||||
| 	registry[t] = p | ||||
| } | ||||
|  | ||||
| // TypeURL returns the type url for a registered type. | ||||
| func TypeURL(v interface{}) (string, error) { | ||||
| 	mu.Lock() | ||||
| 	u, ok := registry[tryDereference(v)] | ||||
| 	mu.Unlock() | ||||
| 	if !ok { | ||||
| 		// fallback to the proto registry if it is a proto message | ||||
| 		pb, ok := v.(proto.Message) | ||||
| 		if !ok { | ||||
| 			return "", errors.Wrapf(ErrNotFound, "type %s", reflect.TypeOf(v)) | ||||
| 		} | ||||
| 		return proto.MessageName(pb), nil | ||||
| 	} | ||||
| 	return u, nil | ||||
| } | ||||
|  | ||||
| // Is returns true if the type of the Any is the same as v. | ||||
| func Is(any *types.Any, v interface{}) bool { | ||||
| 	// call to check that v is a pointer | ||||
| 	tryDereference(v) | ||||
| 	url, err := TypeURL(v) | ||||
| 	if err != nil { | ||||
| 		return false | ||||
| 	} | ||||
| 	return any.TypeUrl == url | ||||
| } | ||||
|  | ||||
| // MarshalAny marshals the value v into an any with the correct TypeUrl. | ||||
| // If the provided object is already a proto.Any message, then it will be | ||||
| // returned verbatim. If it is of type proto.Message, it will be marshaled as a | ||||
| // protocol buffer. Otherwise, the object will be marshaled to json. | ||||
| func MarshalAny(v interface{}) (*types.Any, error) { | ||||
| 	var marshal func(v interface{}) ([]byte, error) | ||||
| 	switch t := v.(type) { | ||||
| 	case *types.Any: | ||||
| 		// avoid reserializing the type if we have an any. | ||||
| 		return t, nil | ||||
| 	case proto.Message: | ||||
| 		marshal = func(v interface{}) ([]byte, error) { | ||||
| 			return proto.Marshal(t) | ||||
| 		} | ||||
| 	default: | ||||
| 		marshal = json.Marshal | ||||
| 	} | ||||
|  | ||||
| 	url, err := TypeURL(v) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	data, err := marshal(v) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	return &types.Any{ | ||||
| 		TypeUrl: url, | ||||
| 		Value:   data, | ||||
| 	}, nil | ||||
| } | ||||
|  | ||||
| // UnmarshalAny unmarshals the any type into a concrete type. | ||||
| func UnmarshalAny(any *types.Any) (interface{}, error) { | ||||
| 	return UnmarshalByTypeURL(any.TypeUrl, any.Value) | ||||
| } | ||||
|  | ||||
| func UnmarshalByTypeURL(typeURL string, value []byte) (interface{}, error) { | ||||
| 	return unmarshal(typeURL, value, nil) | ||||
| } | ||||
|  | ||||
| func UnmarshalTo(any *types.Any, out interface{}) error { | ||||
| 	return UnmarshalToByTypeURL(any.TypeUrl, any.Value, out) | ||||
| } | ||||
|  | ||||
| func UnmarshalToByTypeURL(typeURL string, value []byte, out interface{}) error { | ||||
| 	_, err := unmarshal(typeURL, value, out) | ||||
| 	return err | ||||
| } | ||||
|  | ||||
| func unmarshal(typeURL string, value []byte, v interface{}) (interface{}, error) { | ||||
| 	t, err := getTypeByUrl(typeURL) | ||||
| 	if err != nil { | ||||
| 		return nil, err | ||||
| 	} | ||||
|  | ||||
| 	if v == nil { | ||||
| 		v = reflect.New(t.t).Interface() | ||||
| 	} else { | ||||
| 		// Validate interface type provided by client | ||||
| 		vURL, err := TypeURL(v) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		if typeURL != vURL { | ||||
| 			return nil, errors.Errorf("can't unmarshal type %q to output %q", typeURL, vURL) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if t.isProto { | ||||
| 		err = proto.Unmarshal(value, v.(proto.Message)) | ||||
| 	} else { | ||||
| 		err = json.Unmarshal(value, v) | ||||
| 	} | ||||
|  | ||||
| 	return v, err | ||||
| } | ||||
|  | ||||
| type urlType struct { | ||||
| 	t       reflect.Type | ||||
| 	isProto bool | ||||
| } | ||||
|  | ||||
| func getTypeByUrl(url string) (urlType, error) { | ||||
| 	for t, u := range registry { | ||||
| 		if u == url { | ||||
| 			return urlType{ | ||||
| 				t: t, | ||||
| 			}, nil | ||||
| 		} | ||||
| 	} | ||||
| 	// fallback to proto registry | ||||
| 	t := proto.MessageType(url) | ||||
| 	if t != nil { | ||||
| 		return urlType{ | ||||
| 			// get the underlying Elem because proto returns a pointer to the type | ||||
| 			t:       t.Elem(), | ||||
| 			isProto: true, | ||||
| 		}, nil | ||||
| 	} | ||||
| 	return urlType{}, errors.Wrapf(ErrNotFound, "type with url %s", url) | ||||
| } | ||||
|  | ||||
| func tryDereference(v interface{}) reflect.Type { | ||||
| 	t := reflect.TypeOf(v) | ||||
| 	if t.Kind() == reflect.Ptr { | ||||
| 		// require check of pointer but dereference to register | ||||
| 		return t.Elem() | ||||
| 	} | ||||
| 	panic("v is not a pointer to a type") | ||||
| } | ||||
							
								
								
									
										58
									
								
								vendor/github.com/docker/cli/AUTHORS
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										58
									
								
								vendor/github.com/docker/cli/AUTHORS
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -8,6 +8,7 @@ Aaron.L.Xu <likexu@harmonycloud.cn> | ||||
| Abdur Rehman <abdur_rehman@mentor.com> | ||||
| Abhinandan Prativadi <abhi@docker.com> | ||||
| Abin Shahab <ashahab@altiscale.com> | ||||
| Abreto FU <public@abreto.email> | ||||
| Ace Tang <aceapril@126.com> | ||||
| Addam Hardy <addam.hardy@gmail.com> | ||||
| Adolfo Ochagavía <aochagavia92@gmail.com> | ||||
| @@ -17,12 +18,15 @@ Adrien Folie <folie.adrien@gmail.com> | ||||
| Ahmet Alp Balkan <ahmetb@microsoft.com> | ||||
| Aidan Feldman <aidan.feldman@gmail.com> | ||||
| Aidan Hobson Sayers <aidanhs@cantab.net> | ||||
| AJ Bowen <aj@gandi.net> | ||||
| Akihiro Suda <suda.akihiro@lab.ntt.co.jp> | ||||
| AJ Bowen <aj@soulshake.net> | ||||
| Akhil Mohan <akhil.mohan@mayadata.io> | ||||
| Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp> | ||||
| Akim Demaille <akim.demaille@docker.com> | ||||
| Alan Thompson <cloojure@gmail.com> | ||||
| Albert Callarisa <shark234@gmail.com> | ||||
| Albin Kerouanton <albin@akerouanton.name> | ||||
| Aleksa Sarai <asarai@suse.de> | ||||
| Aleksander Piotrowski <apiotrowski312@gmail.com> | ||||
| Alessandro Boch <aboch@tetrationanalytics.com> | ||||
| Alex Mavrogiannis <alex.mavrogiannis@docker.com> | ||||
| Alex Mayer <amayer5125@gmail.com> | ||||
| @@ -40,6 +44,7 @@ Amir Goldstein <amir73il@aquasec.com> | ||||
| Amit Krishnan <amit.krishnan@oracle.com> | ||||
| Amit Shukla <amit.shukla@docker.com> | ||||
| Amy Lindburg <amy.lindburg@docker.com> | ||||
| Anca Iordache <anca.iordache@docker.com> | ||||
| Anda Xu <anda.xu@docker.com> | ||||
| Andrea Luzzardi <aluzzardi@gmail.com> | ||||
| Andreas Köhler <andi5.py@gmx.net> | ||||
| @@ -49,6 +54,7 @@ Andrew Macpherson <hopscotch23@gmail.com> | ||||
| Andrew McDonnell <bugs@andrewmcdonnell.net> | ||||
| Andrew Po <absourd.noise@gmail.com> | ||||
| Andrey Petrov <andrey.petrov@shazow.net> | ||||
| Andrii Berehuliak <berkusandrew@gmail.com> | ||||
| André Martins <aanm90@gmail.com> | ||||
| Andy Goldstein <agoldste@redhat.com> | ||||
| Andy Rothfusz <github@developersupport.net> | ||||
| @@ -61,7 +67,9 @@ Antonis Kalipetis <akalipetis@gmail.com> | ||||
| Anusha Ragunathan <anusha.ragunathan@docker.com> | ||||
| Ao Li <la9249@163.com> | ||||
| Arash Deshmeh <adeshmeh@ca.ibm.com> | ||||
| Arko Dasgupta <arko.dasgupta@docker.com> | ||||
| Arnaud Porterie <arnaud.porterie@docker.com> | ||||
| Arthur Peka <arthur.peka@outlook.com> | ||||
| Ashwini Oruganti <ashwini.oruganti@gmail.com> | ||||
| Azat Khuyiyakhmetov <shadow_uz@mail.ru> | ||||
| Bardia Keyoumarsi <bkeyouma@ucsc.edu> | ||||
| @@ -87,6 +95,7 @@ Brent Salisbury <brent.salisbury@docker.com> | ||||
| Bret Fisher <bret@bretfisher.com> | ||||
| Brian (bex) Exelbierd <bexelbie@redhat.com> | ||||
| Brian Goff <cpuguy83@gmail.com> | ||||
| Brian Wieder <brian@4wieders.com> | ||||
| Bryan Bess <squarejaw@bsbess.com> | ||||
| Bryan Boreham <bjboreham@gmail.com> | ||||
| Bryan Murphy <bmurphy1976@gmail.com> | ||||
| @@ -95,6 +104,7 @@ Cameron Spear <cameronspear@gmail.com> | ||||
| Cao Weiwei <cao.weiwei30@zte.com.cn> | ||||
| Carlo Mion <mion00@gmail.com> | ||||
| Carlos Alexandro Becker <caarlos0@gmail.com> | ||||
| Carlos de Paula <me@carlosedp.com> | ||||
| Ce Gao <ce.gao@outlook.com> | ||||
| Cedric Davies <cedricda@microsoft.com> | ||||
| Cezar Sa Espinola <cezarsa@gmail.com> | ||||
| @@ -128,26 +138,31 @@ Coenraad Loubser <coenraad@wish.org.za> | ||||
| Colin Hebert <hebert.colin@gmail.com> | ||||
| Collin Guarino <collin.guarino@gmail.com> | ||||
| Colm Hally <colmhally@gmail.com> | ||||
| Comical Derskeal <27731088+derskeal@users.noreply.github.com> | ||||
| Corey Farrell <git@cfware.com> | ||||
| Corey Quon <corey.quon@docker.com> | ||||
| Craig Wilhite <crwilhit@microsoft.com> | ||||
| Cristian Staretu <cristian.staretu@gmail.com> | ||||
| Daehyeok Mun <daehyeok@gmail.com> | ||||
| Dafydd Crosby <dtcrsby@gmail.com> | ||||
| Daisuke Ito <itodaisuke00@gmail.com> | ||||
| dalanlan <dalanlan925@gmail.com> | ||||
| Damien Nadé <github@livna.org> | ||||
| Dan Cotora <dan@bluevision.ro> | ||||
| Daniel Artine <daniel.artine@ufrj.br> | ||||
| Daniel Cassidy <mail@danielcassidy.me.uk> | ||||
| Daniel Dao <dqminh@cloudflare.com> | ||||
| Daniel Farrell <dfarrell@redhat.com> | ||||
| Daniel Gasienica <daniel@gasienica.ch> | ||||
| Daniel Goosen <daniel.goosen@surveysampling.com> | ||||
| Daniel Helfand <dhelfand@redhat.com> | ||||
| Daniel Hiltgen <daniel.hiltgen@docker.com> | ||||
| Daniel J Walsh <dwalsh@redhat.com> | ||||
| Daniel Nephin <dnephin@docker.com> | ||||
| Daniel Norberg <dano@spotify.com> | ||||
| Daniel Watkins <daniel@daniel-watkins.co.uk> | ||||
| Daniel Zhang <jmzwcn@gmail.com> | ||||
| Daniil Nikolenko <qoo2p5@gmail.com> | ||||
| Danny Berger <dpb587@gmail.com> | ||||
| Darren Shepherd <darren.s.shepherd@gmail.com> | ||||
| Darren Stahl <darst@microsoft.com> | ||||
| @@ -180,13 +195,15 @@ Dima Stopel <dima@twistlock.com> | ||||
| Dimitry Andric <d.andric@activevideo.com> | ||||
| Ding Fei <dingfei@stars.org.cn> | ||||
| Diogo Monica <diogo@docker.com> | ||||
| Djordje Lukic <djordje.lukic@docker.com> | ||||
| Dmitry Gusev <dmitry.gusev@gmail.com> | ||||
| Dmitry Smirnov <onlyjob@member.fsf.org> | ||||
| Dmitry V. Krivenok <krivenok.dmitry@gmail.com> | ||||
| Dominik Braun <dominik.braun@nbsp.de> | ||||
| Don Kjer <don.kjer@gmail.com> | ||||
| Dong Chen <dongluo.chen@docker.com> | ||||
| Doug Davis <dug@us.ibm.com> | ||||
| Drew Erny <drew.erny@docker.com> | ||||
| Drew Erny <derny@mirantis.com> | ||||
| Ed Costello <epc@epcostello.com> | ||||
| Elango Sivanandam <elango.siva@docker.com> | ||||
| Eli Uriegas <eli.uriegas@docker.com> | ||||
| @@ -249,6 +266,7 @@ Harald Albers <github@albersweb.de> | ||||
| Harold Cooper <hrldcpr@gmail.com> | ||||
| Harry Zhang <harryz@hyper.sh> | ||||
| He Simei <hesimei@zju.edu.cn> | ||||
| Hector S <hfsam88@gmail.com> | ||||
| Helen Xie <chenjg@harmonycloud.cn> | ||||
| Henning Sprang <henning.sprang@gmail.com> | ||||
| Henry N <henrynmail-github@yahoo.de> | ||||
| @@ -256,6 +274,7 @@ Hernan Garcia <hernandanielg@gmail.com> | ||||
| Hongbin Lu <hongbin034@gmail.com> | ||||
| Hu Keping <hukeping@huawei.com> | ||||
| Huayi Zhang <irachex@gmail.com> | ||||
| Hugo Gabriel Eyherabide <hugogabriel.eyherabide@gmail.com> | ||||
| huqun <huqun@zju.edu.cn> | ||||
| Huu Nguyen <huu@prismskylabs.com> | ||||
| Hyzhou Zhy <hyzhou.zhy@alibaba-inc.com> | ||||
| @@ -297,7 +316,7 @@ Jeremy Unruh <jeremybunruh@gmail.com> | ||||
| Jeremy Yallop <yallop@docker.com> | ||||
| Jeroen Franse <jeroenfranse@gmail.com> | ||||
| Jesse Adametz <jesseadametz@gmail.com> | ||||
| Jessica Frazelle <jessfraz@google.com> | ||||
| Jessica Frazelle <jess@oxide.computer> | ||||
| Jezeniel Zapanta <jpzapanta22@gmail.com> | ||||
| Jian Zhang <zhangjian.fnst@cn.fujitsu.com> | ||||
| Jie Luo <luo612@zju.edu.cn> | ||||
| @@ -308,6 +327,7 @@ Jimmy Song <rootsongjc@gmail.com> | ||||
| jimmyxian <jimmyxian2004@yahoo.com.cn> | ||||
| Jintao Zhang <zhangjintao9020@gmail.com> | ||||
| Joao Fernandes <joao.fernandes@docker.com> | ||||
| Joe Abbey <joe.abbey@gmail.com> | ||||
| Joe Doliner <jdoliner@pachyderm.io> | ||||
| Joe Gordon <joe.gordon0@gmail.com> | ||||
| Joel Handwell <joelhandwell@gmail.com> | ||||
| @@ -317,7 +337,7 @@ Johan Euphrosine <proppy@google.com> | ||||
| Johannes 'fish' Ziemke <github@freigeist.org> | ||||
| John Feminella <jxf@jxf.me> | ||||
| John Harris <john@johnharris.io> | ||||
| John Howard (VM) <John.Howard@microsoft.com> | ||||
| John Howard <github@lowenna.com> | ||||
| John Laswell <john.n.laswell@gmail.com> | ||||
| John Maguire <jmaguire@duosecurity.com> | ||||
| John Mulhausen <john@docker.com> | ||||
| @@ -326,12 +346,15 @@ John Stephens <johnstep@docker.com> | ||||
| John Tims <john.k.tims@gmail.com> | ||||
| John V. Martinez <jvmatl@gmail.com> | ||||
| John Willis <john.willis@docker.com> | ||||
| Jon Johnson <jonjohnson@google.com> | ||||
| Jonatas Baldin <jonatas.baldin@gmail.com> | ||||
| Jonathan Boulle <jonathanboulle@gmail.com> | ||||
| Jonathan Lee <jonjohn1232009@gmail.com> | ||||
| Jonathan Lomas <jonathan@floatinglomas.ca> | ||||
| Jonathan McCrohan <jmccrohan@gmail.com> | ||||
| Jonh Wendell <jonh.wendell@redhat.com> | ||||
| Jordan Jennings <jjn2009@gmail.com> | ||||
| Jose J. Escobar <53836904+jescobar-docker@users.noreply.github.com> | ||||
| Joseph Kern <jkern@semafour.net> | ||||
| Josh Bodah <jb3689@yahoo.com> | ||||
| Josh Chorlton <jchorlton@gmail.com> | ||||
| @@ -369,6 +392,7 @@ Kevin Kern <kaiwentan@harmonycloud.cn> | ||||
| Kevin Kirsche <Kev.Kirsche+GitHub@gmail.com> | ||||
| Kevin Meredith <kevin.m.meredith@gmail.com> | ||||
| Kevin Richardson <kevin@kevinrichardson.co> | ||||
| Kevin Woblick <mail@kovah.de> | ||||
| khaled souf <khaled.souf@gmail.com> | ||||
| Kim Eik <kim@heldig.org> | ||||
| Kir Kolyshkin <kolyshkin@gmail.com> | ||||
| @@ -406,13 +430,16 @@ Luca Favatella <luca.favatella@erlang-solutions.com> | ||||
| Luca Marturana <lucamarturana@gmail.com> | ||||
| Lucas Chan <lucas-github@lucaschan.com> | ||||
| Luka Hartwig <mail@lukahartwig.de> | ||||
| Lukas Heeren <lukas-heeren@hotmail.com> | ||||
| Lukasz Zajaczkowski <Lukasz.Zajaczkowski@ts.fujitsu.com> | ||||
| Lydell Manganti <LydellManganti@users.noreply.github.com> | ||||
| Lénaïc Huard <lhuard@amadeus.com> | ||||
| Ma Shimiao <mashimiao.fnst@cn.fujitsu.com> | ||||
| Mabin <bin.ma@huawei.com> | ||||
| Maciej Kalisz <maciej.d.kalisz@gmail.com> | ||||
| Madhav Puri <madhav.puri@gmail.com> | ||||
| Madhu Venugopal <madhu@socketplane.io> | ||||
| Madhur Batra <madhurbatra097@gmail.com> | ||||
| Malte Janduda <mail@janduda.net> | ||||
| Manjunath A Kumatagi <mkumatag@in.ibm.com> | ||||
| Mansi Nahar <mmn4185@rit.edu> | ||||
| @@ -422,6 +449,7 @@ Marco Mariani <marco.mariani@alterway.fr> | ||||
| Marco Vedovati <mvedovati@suse.com> | ||||
| Marcus Martins <marcus@docker.com> | ||||
| Marianna Tessel <mtesselh@gmail.com> | ||||
| Marius Ileana <marius.ileana@gmail.com> | ||||
| Marius Sturm <marius@graylog.com> | ||||
| Mark Oates <fl0yd@me.com> | ||||
| Marsh Macy <marsma@microsoft.com> | ||||
| @@ -467,12 +495,14 @@ mikelinjie <294893458@qq.com> | ||||
| Mikhail Vasin <vasin@cloud-tv.ru> | ||||
| Milind Chawre <milindchawre@gmail.com> | ||||
| Mindaugas Rukas <momomg@gmail.com> | ||||
| Miroslav Gula <miroslav.gula@naytrolabs.com> | ||||
| Misty Stanley-Jones <misty@docker.com> | ||||
| Mohammad Banikazemi <mb@us.ibm.com> | ||||
| Mohammed Aaqib Ansari <maaquib@gmail.com> | ||||
| Mohini Anne Dsouza <mohini3917@gmail.com> | ||||
| Moorthy RS <rsmoorthy@gmail.com> | ||||
| Morgan Bauer <mbauer@us.ibm.com> | ||||
| Morten Hekkvang <morten.hekkvang@sbab.se> | ||||
| Moysés Borges <moysesb@gmail.com> | ||||
| Mrunal Patel <mrunalp@gmail.com> | ||||
| muicoder <muicoder@gmail.com> | ||||
| @@ -503,9 +533,11 @@ Nishant Totla <nishanttotla@gmail.com> | ||||
| NIWA Hideyuki <niwa.niwa@nifty.ne.jp> | ||||
| Noah Treuhaft <noah.treuhaft@docker.com> | ||||
| O.S. Tezer <ostezer@gmail.com> | ||||
| Odin Ugedal <odin@ugedal.com> | ||||
| ohmystack <jun.jiang02@ele.me> | ||||
| Olle Jonsson <olle.jonsson@gmail.com> | ||||
| Olli Janatuinen <olli.janatuinen@gmail.com> | ||||
| Oscar Wieman <oscrx@icloud.com> | ||||
| Otto Kekäläinen <otto@seravo.fi> | ||||
| Ovidio Mallo <ovidio.mallo@gmail.com> | ||||
| Pascal Borreli <pascal@borreli.com> | ||||
| @@ -515,6 +547,7 @@ Patrick Lang <plang@microsoft.com> | ||||
| Paul <paul9869@gmail.com> | ||||
| Paul Kehrer <paul.l.kehrer@gmail.com> | ||||
| Paul Lietar <paul@lietar.net> | ||||
| Paul Mulders <justinkb@gmail.com> | ||||
| Paul Weaver <pauweave@cisco.com> | ||||
| Pavel Pospisil <pospispa@gmail.com> | ||||
| Paweł Szczekutowicz <pszczekutowicz@gmail.com> | ||||
| @@ -541,6 +574,7 @@ Qiang Huang <h.huangqiang@huawei.com> | ||||
| Qinglan Peng <qinglanpeng@zju.edu.cn> | ||||
| qudongfang <qudongfang@gmail.com> | ||||
| Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com> | ||||
| Rahul Zoldyck <rahulzoldyck@gmail.com> | ||||
| Ravi Shekhar Jethani <rsjethani@gmail.com> | ||||
| Ray Tsang <rayt@google.com> | ||||
| Reficul <xuzhenglun@gmail.com> | ||||
| @@ -553,6 +587,7 @@ Richard Scothern <richard.scothern@gmail.com> | ||||
| Rick Wieman <git@rickw.nl> | ||||
| Ritesh H Shukla <sritesh@vmware.com> | ||||
| Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com> | ||||
| Rob Gulewich <rgulewich@netflix.com> | ||||
| Robert Wallis <smilingrob@gmail.com> | ||||
| Robin Naundorf <r.naundorf@fh-muenster.de> | ||||
| Robin Speekenbrink <robin@kingsquare.nl> | ||||
| @@ -574,10 +609,14 @@ Sainath Grandhi <sainath.grandhi@intel.com> | ||||
| Sakeven Jiang <jc5930@sina.cn> | ||||
| Sally O'Malley <somalley@redhat.com> | ||||
| Sam Neirinck <sam@samneirinck.com> | ||||
| Samarth Shah <samashah@microsoft.com> | ||||
| Sambuddha Basu <sambuddhabasu1@gmail.com> | ||||
| Sami Tabet <salph.tabet@gmail.com> | ||||
| Samuel Cochran <sj26@sj26.com> | ||||
| Samuel Karp <skarp@amazon.com> | ||||
| Santhosh Manohar <santhosh@docker.com> | ||||
| Sargun Dhillon <sargun@netflix.com> | ||||
| Saswat Bhattacharya <sas.saswat@gmail.com> | ||||
| Scott Brenner <scott@scottbrenner.me> | ||||
| Scott Collier <emailscottcollier@gmail.com> | ||||
| Sean Christopherson <sean.j.christopherson@intel.com> | ||||
| @@ -598,6 +637,7 @@ sidharthamani <sid@rancher.com> | ||||
| Silvin Lubecki <silvin.lubecki@docker.com> | ||||
| Simei He <hesimei@zju.edu.cn> | ||||
| Simon Ferquel <simon.ferquel@docker.com> | ||||
| Simon Heimberg <simon.heimberg@heimberg-ea.ch> | ||||
| Sindhu S <sindhus@live.in> | ||||
| Slava Semushin <semushin@redhat.com> | ||||
| Solomon Hykes <solomon@docker.com> | ||||
| @@ -627,7 +667,10 @@ TAGOMORI Satoshi <tagomoris@gmail.com> | ||||
| taiji-tech <csuhqg@foxmail.com> | ||||
| Taylor Jones <monitorjbl@gmail.com> | ||||
| Tejaswini Duggaraju <naduggar@microsoft.com> | ||||
| Tengfei Wang <tfwang@alauda.io> | ||||
| Teppei Fukuda <knqyf263@gmail.com> | ||||
| Thatcher Peskens <thatcher@docker.com> | ||||
| Thibault Coupin <thibault.coupin@gmail.com> | ||||
| Thomas Gazagnaire <thomas@gazagnaire.org> | ||||
| Thomas Krzero <thomas.kovatchitch@gmail.com> | ||||
| Thomas Leonard <thomas.leonard@docker.com> | ||||
| @@ -639,6 +682,7 @@ Tianyi Wang <capkurmagati@gmail.com> | ||||
| Tibor Vass <teabee89@gmail.com> | ||||
| Tim Dettrick <t.dettrick@uq.edu.au> | ||||
| Tim Hockin <thockin@google.com> | ||||
| Tim Sampson <tim@sampson.fi> | ||||
| Tim Smith <timbot@google.com> | ||||
| Tim Waugh <twaugh@redhat.com> | ||||
| Tim Wraight <tim.wraight@tangentlabs.co.uk> | ||||
| @@ -663,9 +707,11 @@ Tristan Carel <tristan@cogniteev.com> | ||||
| Tycho Andersen <tycho@docker.com> | ||||
| Tycho Andersen <tycho@tycho.ws> | ||||
| uhayate <uhayate.gong@daocloud.io> | ||||
| Ulrich Bareth <ulrich.bareth@gmail.com> | ||||
| Ulysses Souza <ulysses.souza@docker.com> | ||||
| Umesh Yadav <umesh4257@gmail.com> | ||||
| Valentin Lorentz <progval+git@progval.net> | ||||
| Venkateswara Reddy Bukkasamudram <bukkasamudram@outlook.com> | ||||
| Veres Lajos <vlajos@gmail.com> | ||||
| Victor Vieux <victor.vieux@docker.com> | ||||
| Victoria Bialas <victoria.bialas@docker.com> | ||||
| @@ -683,6 +729,7 @@ Wang Long <long.wanglong@huawei.com> | ||||
| Wang Ping <present.wp@icloud.com> | ||||
| Wang Xing <hzwangxing@corp.netease.com> | ||||
| Wang Yuexiao <wang.yuexiao@zte.com.cn> | ||||
| Wang Yumu <37442693@qq.com> | ||||
| Wataru Ishida <ishida.wataru@lab.ntt.co.jp> | ||||
| Wayne Song <wsong@docker.com> | ||||
| Wen Cheng Ma <wenchma@cn.ibm.com> | ||||
| @@ -691,6 +738,7 @@ Wes Morgan <cap10morgan@gmail.com> | ||||
| Wewang Xiaorenfine <wang.xiaoren@zte.com.cn> | ||||
| William Henry <whenry@redhat.com> | ||||
| Xianglin Gao <xlgao@zju.edu.cn> | ||||
| Xiaodong Liu <liuxiaodong@loongson.cn> | ||||
| Xiaodong Zhang <a4012017@sina.com> | ||||
| Xiaoxi He <xxhe@alauda.io> | ||||
| Xinbo Weng <xihuanbo_0521@zju.edu.cn> | ||||
|   | ||||
							
								
								
									
										5
									
								
								vendor/github.com/docker/cli/cli-plugins/manager/error.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								vendor/github.com/docker/cli/cli-plugins/manager/error.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -25,6 +25,11 @@ func (e *pluginError) Cause() error { | ||||
| 	return e.cause | ||||
| } | ||||
|  | ||||
| // Unwrap provides compatibility for Go 1.13 error chains. | ||||
| func (e *pluginError) Unwrap() error { | ||||
| 	return e.cause | ||||
| } | ||||
|  | ||||
| // MarshalText marshalls the pluginError into a textual form. | ||||
| func (e *pluginError) MarshalText() (text []byte, err error) { | ||||
| 	return []byte(e.cause.Error()), nil | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/docker/cli/cli-plugins/manager/manager.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/docker/cli/cli-plugins/manager/manager.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -11,8 +11,8 @@ import ( | ||||
|  | ||||
| 	"github.com/docker/cli/cli/command" | ||||
| 	"github.com/docker/cli/cli/config" | ||||
| 	"github.com/fvbommel/sortorder" | ||||
| 	"github.com/spf13/cobra" | ||||
| 	"vbom.ml/util/sortorder" | ||||
| ) | ||||
|  | ||||
| // ReexecEnvvar is the name of an ennvar which is set to the command | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/docker/cli/cli-plugins/manager/metadata.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/docker/cli/cli-plugins/manager/metadata.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -10,7 +10,7 @@ const ( | ||||
| 	MetadataSubcommandName = "docker-cli-plugin-metadata" | ||||
| ) | ||||
|  | ||||
| // Metadata provided by the plugin. See docs/extend/cli_plugins.md for canonical information. | ||||
| // Metadata provided by the plugin. | ||||
| type Metadata struct { | ||||
| 	// SchemaVersion describes the version of this struct. Mandatory, must be "0.1.0" | ||||
| 	SchemaVersion string `json:",omitempty"` | ||||
|   | ||||
							
								
								
									
										7
									
								
								vendor/github.com/docker/cli/cli-plugins/plugin/plugin.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										7
									
								
								vendor/github.com/docker/cli/cli-plugins/plugin/plugin.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -24,7 +24,8 @@ import ( | ||||
| // called. | ||||
| var PersistentPreRunE func(*cobra.Command, []string) error | ||||
|  | ||||
| func runPlugin(dockerCli *command.DockerCli, plugin *cobra.Command, meta manager.Metadata) error { | ||||
| // RunPlugin executes the specified plugin command | ||||
| func RunPlugin(dockerCli *command.DockerCli, plugin *cobra.Command, meta manager.Metadata) error { | ||||
| 	tcmd := newPluginCommand(dockerCli, plugin, meta) | ||||
|  | ||||
| 	var persistentPreRunOnce sync.Once | ||||
| @@ -60,7 +61,7 @@ func Run(makeCmd func(command.Cli) *cobra.Command, meta manager.Metadata) { | ||||
|  | ||||
| 	plugin := makeCmd(dockerCli) | ||||
|  | ||||
| 	if err := runPlugin(dockerCli, plugin, meta); err != nil { | ||||
| 	if err := RunPlugin(dockerCli, plugin, meta); err != nil { | ||||
| 		if sterr, ok := err.(cli.StatusError); ok { | ||||
| 			if sterr.Status != "" { | ||||
| 				fmt.Fprintln(dockerCli.Err(), sterr.Status) | ||||
| @@ -127,7 +128,7 @@ func newPluginCommand(dockerCli *command.DockerCli, plugin *cobra.Command, meta | ||||
| 	} | ||||
| 	opts, flags := cli.SetupPluginRootCommand(cmd) | ||||
|  | ||||
| 	cmd.SetOutput(dockerCli.Out()) | ||||
| 	cmd.SetOut(dockerCli.Out()) | ||||
|  | ||||
| 	cmd.AddCommand( | ||||
| 		plugin, | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/docker/cli/cli/cobra.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/docker/cli/cli/cobra.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -9,7 +9,7 @@ import ( | ||||
| 	"github.com/docker/cli/cli/command" | ||||
| 	cliconfig "github.com/docker/cli/cli/config" | ||||
| 	cliflags "github.com/docker/cli/cli/flags" | ||||
| 	"github.com/docker/docker/pkg/term" | ||||
| 	"github.com/moby/term" | ||||
| 	"github.com/pkg/errors" | ||||
| 	"github.com/spf13/cobra" | ||||
| 	"github.com/spf13/pflag" | ||||
|   | ||||
							
								
								
									
										28
									
								
								vendor/github.com/docker/cli/cli/command/cli.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										28
									
								
								vendor/github.com/docker/cli/cli/command/cli.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -8,6 +8,8 @@ import ( | ||||
| 	"path/filepath" | ||||
| 	"runtime" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/docker/cli/cli/config" | ||||
| 	cliconfig "github.com/docker/cli/cli/config" | ||||
| @@ -27,8 +29,8 @@ import ( | ||||
| 	"github.com/docker/docker/api/types" | ||||
| 	registrytypes "github.com/docker/docker/api/types/registry" | ||||
| 	"github.com/docker/docker/client" | ||||
| 	"github.com/docker/docker/pkg/term" | ||||
| 	"github.com/docker/go-connections/tlsconfig" | ||||
| 	"github.com/moby/term" | ||||
| 	"github.com/pkg/errors" | ||||
| 	"github.com/spf13/cobra" | ||||
| 	"github.com/theupdateframework/notary" | ||||
| @@ -115,7 +117,7 @@ func (cli *DockerCli) In() *streams.In { | ||||
| // ShowHelp shows the command help. | ||||
| func ShowHelp(err io.Writer) func(*cobra.Command, []string) error { | ||||
| 	return func(cmd *cobra.Command, args []string) error { | ||||
| 		cmd.SetOutput(err) | ||||
| 		cmd.SetOut(err) | ||||
| 		cmd.HelpFunc()(cmd, args) | ||||
| 		return nil | ||||
| 	} | ||||
| @@ -142,7 +144,9 @@ func (cli *DockerCli) ServerInfo() ServerInfo { | ||||
| // ClientInfo returns the client details for the cli | ||||
| func (cli *DockerCli) ClientInfo() ClientInfo { | ||||
| 	if cli.clientInfo == nil { | ||||
| 		_ = cli.loadClientInfo() | ||||
| 		if err := cli.loadClientInfo(); err != nil { | ||||
| 			panic(err) | ||||
| 		} | ||||
| 	} | ||||
| 	return *cli.clientInfo | ||||
| } | ||||
| @@ -270,11 +274,12 @@ func (cli *DockerCli) Initialize(opts *cliflags.ClientOptions, ops ...Initialize | ||||
| 			return err | ||||
| 		} | ||||
| 	} | ||||
| 	err = cli.loadClientInfo() | ||||
| 	if err != nil { | ||||
| 	cli.initializeFromClient() | ||||
|  | ||||
| 	if err := cli.loadClientInfo(); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	cli.initializeFromClient() | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| @@ -365,7 +370,16 @@ func isEnabled(value string) (bool, error) { | ||||
| } | ||||
|  | ||||
| func (cli *DockerCli) initializeFromClient() { | ||||
| 	ping, err := cli.client.Ping(context.Background()) | ||||
| 	ctx := context.Background() | ||||
| 	if strings.HasPrefix(cli.DockerEndpoint().Host, "tcp://") { | ||||
| 		// @FIXME context.WithTimeout doesn't work with connhelper / ssh connections | ||||
| 		// time="2020-04-10T10:16:26Z" level=warning msg="commandConn.CloseWrite: commandconn: failed to wait: signal: killed" | ||||
| 		var cancel func() | ||||
| 		ctx, cancel = context.WithTimeout(ctx, 2*time.Second) | ||||
| 		defer cancel() | ||||
| 	} | ||||
|  | ||||
| 	ping, err := cli.client.Ping(ctx) | ||||
| 	if err != nil { | ||||
| 		// Default to true if we fail to connect to daemon | ||||
| 		cli.serverInfo = ServerInfo{HasExperimental: true} | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/docker/cli/cli/command/cli_options.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/docker/cli/cli/command/cli_options.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -9,7 +9,7 @@ import ( | ||||
| 	"github.com/docker/cli/cli/context/docker" | ||||
| 	"github.com/docker/cli/cli/context/store" | ||||
| 	"github.com/docker/cli/cli/streams" | ||||
| 	"github.com/docker/docker/pkg/term" | ||||
| 	"github.com/moby/term" | ||||
| ) | ||||
|  | ||||
| // DockerCliOption applies a modification on a DockerCli. | ||||
|   | ||||
							
								
								
									
										45
									
								
								vendor/github.com/docker/cli/cli/command/context.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										45
									
								
								vendor/github.com/docker/cli/cli/command/context.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -1,6 +1,7 @@ | ||||
| package command | ||||
|  | ||||
| import ( | ||||
| 	"encoding/json" | ||||
| 	"errors" | ||||
|  | ||||
| 	"github.com/docker/cli/cli/context/store" | ||||
| @@ -8,8 +9,48 @@ import ( | ||||
|  | ||||
| // DockerContext is a typed representation of what we put in Context metadata | ||||
| type DockerContext struct { | ||||
| 	Description       string       `json:",omitempty"` | ||||
| 	StackOrchestrator Orchestrator `json:",omitempty"` | ||||
| 	Description       string | ||||
| 	StackOrchestrator Orchestrator | ||||
| 	AdditionalFields  map[string]interface{} | ||||
| } | ||||
|  | ||||
| // MarshalJSON implements custom JSON marshalling | ||||
| func (dc DockerContext) MarshalJSON() ([]byte, error) { | ||||
| 	s := map[string]interface{}{} | ||||
| 	if dc.Description != "" { | ||||
| 		s["Description"] = dc.Description | ||||
| 	} | ||||
| 	if dc.StackOrchestrator != "" { | ||||
| 		s["StackOrchestrator"] = dc.StackOrchestrator | ||||
| 	} | ||||
| 	if dc.AdditionalFields != nil { | ||||
| 		for k, v := range dc.AdditionalFields { | ||||
| 			s[k] = v | ||||
| 		} | ||||
| 	} | ||||
| 	return json.Marshal(s) | ||||
| } | ||||
|  | ||||
| // UnmarshalJSON implements custom JSON marshalling | ||||
| func (dc *DockerContext) UnmarshalJSON(payload []byte) error { | ||||
| 	var data map[string]interface{} | ||||
| 	if err := json.Unmarshal(payload, &data); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	for k, v := range data { | ||||
| 		switch k { | ||||
| 		case "Description": | ||||
| 			dc.Description = v.(string) | ||||
| 		case "StackOrchestrator": | ||||
| 			dc.StackOrchestrator = Orchestrator(v.(string)) | ||||
| 		default: | ||||
| 			if dc.AdditionalFields == nil { | ||||
| 				dc.AdditionalFields = make(map[string]interface{}) | ||||
| 			} | ||||
| 			dc.AdditionalFields[k] = v | ||||
| 		} | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // GetDockerContext extracts metadata from stored context metadata | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/docker/cli/cli/command/registry.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/docker/cli/cli/command/registry.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -17,8 +17,8 @@ import ( | ||||
| 	"github.com/docker/distribution/reference" | ||||
| 	"github.com/docker/docker/api/types" | ||||
| 	registrytypes "github.com/docker/docker/api/types/registry" | ||||
| 	"github.com/docker/docker/pkg/term" | ||||
| 	"github.com/docker/docker/registry" | ||||
| 	"github.com/moby/term" | ||||
| 	"github.com/pkg/errors" | ||||
| ) | ||||
|  | ||||
|   | ||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user
	 Tonis Tiigi
					Tonis Tiigi